diff --git a/bash_completion b/bash_completion index 786b1735..60a94e5f 100644 --- a/bash_completion +++ b/bash_completion @@ -1204,42 +1204,6 @@ _known_hosts_real() complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \ ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr -# Linux route(8) completion -# -[ $UNAME = Linux ] && -_route() -{ - local cur prev - - COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} - - if [ "$prev" = dev ]; then - COMPREPLY=( $( ifconfig -a | sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' )) - return 0 - fi - - COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \ - window irtt reject mod dyn reinstate dev \ - default gw' -- $cur ) ) - - COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \ - (while read -d ' ' i; do - [ "$i" == "" ] && continue - # flatten array with spaces on either side, - # otherwise we cannot grep on word - # boundaries of first and last word - COMPREPLY=" ${COMPREPLY[@]} " - # remove word from list of completions - COMPREPLY=( ${COMPREPLY/ $i / } ) - done - echo "${COMPREPLY[@]}") - ) ) - return 0 -} -[ $UNAME = Linux ] && complete -F _route route - # This meta-cd function observes the CDPATH variable, so that cd additionally # completes on directories under those specified in CDPATH. # diff --git a/contrib/net-tools b/contrib/net-tools index 1c3c20aa..a443bd2f 100644 --- a/contrib/net-tools +++ b/contrib/net-tools @@ -72,3 +72,39 @@ _mii_diag() fi } && complete -F _mii_diag $default mii-diag + +# Linux route(8) completion +# +[ $UNAME = Linux ] && +_route() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [ "$prev" = dev ]; then + COMPREPLY=( $( ifconfig -a | sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' )) + return 0 + fi + + COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \ + window irtt reject mod dyn reinstate dev \ + default gw' -- $cur ) ) + + COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \ + (while read -d ' ' i; do + [ "$i" == "" ] && continue + # flatten array with spaces on either side, + # otherwise we cannot grep on word + # boundaries of first and last word + COMPREPLY=" ${COMPREPLY[@]} " + # remove word from list of completions + COMPREPLY=( ${COMPREPLY/ $i / } ) + done + echo "${COMPREPLY[@]}") + ) ) + return 0 +} +[ $UNAME = Linux ] && complete -F _route route