Created
November 12, 2014 11:16
-
-
Save mattmacleod/534c93845b73301049c7 to your computer and use it in GitHub Desktop.
Shell function for showing external and internal IPs
This file contains hidden or 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
function myip() { | |
internalip=`ifconfig | ruby -e "print STDIN.readlines.select { |a| a =~ /inet / }.reject { |a| a =~ /127|172/ }.map { |a| a.split(' ')[1] }.join(', ')"` | |
externalip=`curl -s http://jsonip.com | jq -r .ip | tr -d '\n'` | |
echo "Internal: $internalip" | |
echo "External: $externalip" | |
echo -n $externalip | pbcopy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation of jq (json parser) is needed http://stedolan.github.io/jq/