mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-14 17:07:44 +00:00
__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.
This commit is contained in:
parent
18a116394d
commit
f7e8f8031d
2 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue