a127c4f88e9807c9d5ac58f5424dfc479370c227
- Author
- Niccolò Maggioni <nicco.maggioni@gmail.com>
- Committer
- Niccolò Maggioni <nicco.maggioni@gmail.com>
- Date
Message
'ip' command compatibility and much quicker external IP detection
Diff
1diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
2index 4ae70dfa751dc124c3cb47b83eb1f6c57c34b203..f6641b273e0334532b5c63de35f92a8126d3cbe5 100644
3--- a/plugins/systemadmin/systemadmin.plugin.zsh
4+++ b/plugins/systemadmin/systemadmin.plugin.zsh
5@@ -140,12 +140,16 @@ d0() {
6
7 # gather external ip address
8 geteip() {
9- curl http://ifconfig.me
10+ echo "$(curl -s -S http://ipecho.net/plain)"
11 }
12
13 # determine local IP address
14 getip() {
15- ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
16+ if [ "$(which ip)" != "" ]; then
17+ ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}'
18+ else
19+ ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
20+ fi
21 }
22
23 # Clear zombie processes