One of these two commands do the job:
$ dig +short myip.opendns.com @resolver1.opendns.com
$ dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
One of these two commands do the job:
$ dig +short myip.opendns.com @resolver1.opendns.com
$ dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
Also
curl icanhazip.com
:)