Two very nice ways with different tools to get your external IP on unix-like systems, not dependent on shell you use.
This one I found on this forum, but extracted from whole topic just this useful part of it.
wget -qO- http://icanhazip.com
Another way found in another forum, but even more simple.
curl ifconfig.me
These two ways should be universal on all unix-like systems linux, bsd, os x, solaris .... They're just dependent on tools and external web servers. Another way I founf that is independent on external web server, but only works on some linux VPS( depends on VPS provider networking )
Only for some linux VPS ( usefull in shell scripts )
ip a | grep "eth0" -A 2 | grep "inet" | cut -d " " -f 6 | cut -d / -f 1
In most normal cases this just gets your lan eth0 ip. Just this trick for extracting IP itself from ip a output might be handy for someone interested in shell scripting.
NOTE: I suggest everyone that still uses ifconfig on linux to switch to ip and iw from iwconfig and ifconfig. Because iwconfig and ifconfig is deprecated and no longer evolving in linux. Ifconfig is godlike in BSD but only iw and ip has a future on linux.
Please add more ways to get external IP on unix like shell. I would like to see them. And this can be useful to someone later.
EDIT: ==========================
Just discovered quicker way for that greping of ip output so I think it would be apropriate to update it. So faster way is to replace grep with fgrep it might improve it's speed by few miliseconds or so. But still it is important to notice that sometimes might be better to use fgrep instead of grep.
ip a | fgrep "eth0" -A 2 | fgrep "inet" | cut -d " " -f 6 | cut -d / -f 1