# Linux route(8) completion -*- shell-script -*- [[ $OSTYPE == *linux* ]] || return 1 proc _route { var cur = '', prev = '', words = '', cword = '' _init_completion || return if [[ $prev == dev ]] { _available_interfaces return 0 } # Remove already given options from completions var opt = '', found = '', i = '' for opt in [add del -host -net netmask metric mss window irtt reject mod \ dyn reinstate dev default gw] { set found = 'false' for (( i=1; i < ${#words[@]}-1; i++ )); do [[ ${words[i]} == $opt ]] && found=true && break done $found || setglobal COMPREPLY[${#COMPREPLY[@]}]="$opt" } setglobal COMPREPLY = '( '$( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) } && complete -F _route route # ex: ts=4 sw=4 et filetype=sh