diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2013-02-01 20:40:49 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2013-02-01 20:40:49 +0200 |
commit | 3064e9d707404e5aa59bb8b643d02208fb0f9daa (patch) | |
tree | 472806d79bab6576d014927fec6610c87e39bb9a | |
parent | aa516acdc537b14541cb16424d51af6403321705 (diff) | |
download | bash-completion-3064e9d707404e5aa59bb8b643d02208fb0f9daa.tar.gz |
_available_interfaces: Without -a, try with "ip link" if ifconfig is N/A.
-rw-r--r-- | bash_completion | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bash_completion b/bash_completion index 4b581966..ea8ee507 100644 --- a/bash_completion +++ b/bash_completion @@ -896,18 +896,19 @@ _kernel_versions() # _available_interfaces() { - local cmd + local cmd PATH=$PATH:/sbin if [[ ${1:-} == -w ]]; then cmd="iwconfig" elif [[ ${1:-} == -a ]]; then + # TODO: the corresponding ip link one cmd="ifconfig" else - cmd="ifconfig -a" + cmd="{ ifconfig -a || ip link show; }" fi - COMPREPLY=( $( eval PATH="$PATH:/sbin" $cmd 2>/dev/null | \ - awk '/^[^ \t]/ { print $1 }' ) ) + COMPREPLY=( $( eval $cmd 2>/dev/null | awk \ + '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }' ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) ) } |