Read more →
There is several websites providing a way to query your public IP from the command line, my daily driver is ifconfig.co
It has a rate limit so be careful not to spam it, I've found checking every 60 seconds to be perfectly supported.
You can gather more information like City, Town, Hostname and port as explained on https://ifconfig.co/ , check also https://v6.ifconfig.co/ for IPv6 info.
For a more complete check of your IP including TCP/IP fingerprint, ISP, DNS leaks, check http://ip-api.com or https://www.dnsleaktest.com