Local and External IPs — beautified
Local and External IPs — beautified
Simple ZSH script to get the external and local IPs
IPs script
ip(){
hrline 36
# Gets external IP from opendns.com
print -P "%F{240}|%f %F{$colorInfo}=> External IP%f `dig +short myip.opendns.com @resolver1.opendns.com` %F{240}|%f"
# Get's local IP from ipconfig
print -P "%F{240}|%f %F{$colorSecondary}=> Local IP %f `ipconfig getifaddr en0` %F{240}|%f"
# make line, https://gist.github.com/nvk/5340820
hrline 36
}
</code>
Makes dash "-" lines on demand.
hrline() {
# Checks for stout if none gives a default number
if [ -z "$1" ]
then
local length=50
else
local length="$1"
fi
# Takes stout and uses as length
for i in `seq $length`; do hrline="$hrline-";done
# Prints with ZSH colors
print -P "%F{240}$hrline%f"
# Clears var
hrline=""
}
</code>
Written by Rodolfo Novak
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Zsh
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#