about summary refs log tree commit diff
path: root/Completion/Unix/Type/_bind_addresses
blob: 6042eaf1eb6df9551b736916b7cb68e1bc303f8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#autoload

# @todo In the future it might be useful to have this function take a glob or
# similar to filter out loop-back addresses, only return IPv4/6, etc.

local -a expl tmp cmd=( ifconfig -a )

# A lot of Linux systems have ifconfig, but this is probably safer (and it's
# parsed the same way)
[[ $OSTYPE == linux* ]] && (( $+commands[ip] )) && cmd=( ip addr show )

tmp=( ${(f)"$( _call_program bind-addresses $cmd )"} )
tmp=( ${(@M)tmp##(|[[:space:]]##)inet(|6)(|:)[[:space:]]*} )
tmp=( ${(@)tmp#*inet(|6)(|:)[[:space:]]##} )
tmp=( ${(@)tmp%%[^0-9A-Fa-f:.]*} )

_wanted bind-addresses expl 'bind address' compadd -a "$@" - tmp