From 67f2f1a8842f205d0fe6edd395a795c5935dc4ef Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 20 Sep 2016 00:17:39 -0700 Subject: [PATCH] [Shell] Make localip a function --- dotfiles/lib/shellenv/functions.sh | 5 +++++ dotfiles/lib/shellrc/aliases.sh | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dotfiles/lib/shellenv/functions.sh b/dotfiles/lib/shellenv/functions.sh index fb5a9ec4..aecd923f 100644 --- a/dotfiles/lib/shellenv/functions.sh +++ b/dotfiles/lib/shellenv/functions.sh @@ -448,3 +448,8 @@ function in_git_directory { function which_readlink { readlink -f "$(which $1)" } + +function localip { + command_exists ip && ip addr show + alias localip="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'" +} diff --git a/dotfiles/lib/shellrc/aliases.sh b/dotfiles/lib/shellrc/aliases.sh index 7386b913..abb716fd 100644 --- a/dotfiles/lib/shellrc/aliases.sh +++ b/dotfiles/lib/shellrc/aliases.sh @@ -24,7 +24,6 @@ alias ls="command ls ${colorflag}" # IP addresses alias externalip="dig +short myip.opendns.com @resolver1.opendns.com" -alias localip="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'" alias whois="whois -h whois-servers.net"