__fish_print_{addresses,interaces}: Better OSX/BSD

This commit is contained in:
Fabian Homborg 2015-09-18 12:00:12 +02:00
parent f7e8f8031d
commit b34127e346
2 changed files with 6 additions and 3 deletions

View file

@ -2,7 +2,10 @@ function __fish_print_addresses --description "Print a list of known network add
if command -s ip >/dev/null if command -s ip >/dev/null
command ip --oneline address | cut -d" " -f7 | sed "s:\(.*\)/.*:\1:" command ip --oneline address | cut -d" " -f7 | sed "s:\(.*\)/.*:\1:"
else if command -s ifconfig >/dev/null else if command -s ifconfig >/dev/null
command ifconfig |sgrep 'inet addr'|cut -d : -f 2|cut -d ' ' -f 1 # This is for OSX/BSD
# There's also linux ifconfig but that has at least two different output formats
# is basically dead, and ip is installed on everything now
ifconfig | awk '/^\tinet/ { print $2 } '
end end
end end

View file

@ -4,7 +4,7 @@ function __fish_print_interfaces --description "Print a list of known network in
for i in * for i in *
echo $i echo $i
end end
else else # OSX/BSD
netstat -i -n -a | awk 'NR>2'|awk '{print $1}' command ifconfig -l | tr ' ' '\n'
end end
end end