From a127c4f88e9807c9d5ac58f5424dfc479370c227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Wed, 26 Aug 2015 10:48:01 +0200 Subject: [PATCH 1/3] 'ip' command compatibility and much quicker external IP detection --- plugins/systemadmin/systemadmin.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 4ae70dfa7..f6641b273 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -140,12 +140,16 @@ d0() { # gather external ip address geteip() { - curl http://ifconfig.me + echo "$(curl -s -S http://ipecho.net/plain)" } # determine local IP address getip() { - ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' + if [ "$(which ip)" != "" ]; then + ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' + else + ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' + fi } # Clear zombie processes From 058bbe4f02be67102871d82de6aa194e6b865cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Wed, 26 Aug 2015 10:54:08 +0200 Subject: [PATCH 2/3] General compatibility --- plugins/systemadmin/systemadmin.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index f6641b273..5618ba8f1 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -145,7 +145,7 @@ geteip() { # determine local IP address getip() { - if [ "$(which ip)" != "" ]; then + if [ $(hash | grep '^ip=') ]; then ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' else ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' From d923cebdb34c373597d6f11a0e57e4b73f9f53f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Thu, 27 Aug 2015 11:34:53 +0200 Subject: [PATCH 3/3] Updated with @mcornella suggestions --- plugins/systemadmin/systemadmin.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 5618ba8f1..8c2633355 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -140,12 +140,12 @@ d0() { # gather external ip address geteip() { - echo "$(curl -s -S http://ipecho.net/plain)" + curl -s -S https://icanhazip.com } # determine local IP address getip() { - if [ $(hash | grep '^ip=') ]; then + if (( ${+commands[ip]} )); then ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' else ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'