IPs locais e externos – embelezados

IPs locais e externos – embelezados

Script ZSH simples para obter os IPs externos e locais

Captura de tela

Script de IPs

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>

Gist Link

Cria linhas tracejadas “-” sob demanda.

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>

Gist Link