Last active
June 22, 2018 17:03
-
-
Save ckalegi/5c43a432d8392b60412b23bc78d1374c to your computer and use it in GitHub Desktop.
IP + Location from terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias ip="python ~/myip.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
save myip.py to ~/ | |
add .bash_profile to ~/.bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
r = requests.get('http://ipinfo.io').json() | |
print("\033[96m"+r["ip"]+"\033[90m"+"\n"+r["city"]+", "+r["region"]+", "+r["country"]+"\n"+r["loc"]+"\033[0m") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment