mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-14 17:07:44 +00:00
274be5eeeb
added --all flag to include 0.0.0.0 and :: adapted use of this function in existing completions fixes #7787
15 lines
659 B
Fish
15 lines
659 B
Fish
function __fish_print_addresses --description "List own network addresses with interface as description"
|
|
# if --all is given, also print 0.0.0.0 and ::
|
|
if contains -- --all $argv
|
|
echo -e "0.0.0.0\tall"
|
|
echo -e "::\tall"
|
|
end
|
|
if command -sq ip
|
|
command ip --oneline address | string replace -r '^\d+:\s+(\S+)\s+inet6?\s+([^\s/]+).*' '$2\t$1'
|
|
else if command -sq ifconfig
|
|
# 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
|