I’m always needing to do this so here’s two quick ways.
wget -qO- http://ipecho.net/plain
Or if you prefer curl:
The ifconfig.me site
If you browse this website with your normal browser it will show how to get a lot of information from the command line, using curl, to get just the IP you can use:
Now if windows was just as easy…if you have curl under Windows it is.