diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2015-09-16 23:01:27 +0200 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2015-09-24 15:32:15 +0200 |
commit | 79c22c76bffa7d0e5ced234150c7874c783bd72a (patch) | |
tree | d8bf94efdee0c06421546533aec2fb3e7b3bcd9e /share | |
parent | 20e96df85d575261ac65d5354659061e53ef3c3b (diff) |
__fish_print_{addresses,interfaces}: Add alternative to net_tools
net_tools, which provides `ifconfig` and `netstat`, among other things,
has last been updated in 2013. This means `ifconfig` on linux is
basically dead.
Instead of ifconfig, use `ip` (from iproute2), which is much more powerful and
provides a much more annoying commandline syntax.
Instead of netstat, just look at /sys/class/net.
Diffstat (limited to 'share')
-rw-r--r-- | share/functions/__fish_print_addresses.fish | 6 | ||||
-rw-r--r-- | share/functions/__fish_print_interfaces.fish | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/share/functions/__fish_print_addresses.fish b/share/functions/__fish_print_addresses.fish index 4311b1e8..578c9f63 100644 --- a/share/functions/__fish_print_addresses.fish +++ b/share/functions/__fish_print_addresses.fish @@ -1,4 +1,8 @@ function __fish_print_addresses --description "Print a list of known network addresses" - /sbin/ifconfig | __fish_sgrep 'inet addr'|cut -d : -f 2|cut -d ' ' -f 1 + if command -s ip >/dev/null + command ip --oneline address | cut -d" " -f7 | sed "s:\(.*\)/.*:\1:" + else if command -s ifconfig >/dev/null + command ifconfig |sgrep 'inet addr'|cut -d : -f 2|cut -d ' ' -f 1 + end end diff --git a/share/functions/__fish_print_interfaces.fish b/share/functions/__fish_print_interfaces.fish index cf100056..d9805359 100644 --- a/share/functions/__fish_print_interfaces.fish +++ b/share/functions/__fish_print_interfaces.fish @@ -1,3 +1,10 @@ function __fish_print_interfaces --description "Print a list of known network interfaces" - netstat -i -n -a | awk 'NR>2'|awk '{print $1}' + if test -d /sys/class/net + cd /sys/class/net + for i in * + echo $i + end + else + netstat -i -n -a | awk 'NR>2'|awk '{print $1}' + end end |