From f7e8f8031da7f0f4f6e17fb5443a6358ec5a8e6c Mon Sep 17 00:00:00 2001 From: Fabian Homborg <FHomborg@gmail.com> Date: Wed, 16 Sep 2015 23:01:27 +0200 Subject: [PATCH] __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. --- share/functions/__fish_print_addresses.fish | 6 +++++- 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 4311b1e8d..578c9f632 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 cf100056c..d9805359a 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