diff options
Diffstat (limited to 'completions/route')
-rw-r--r-- | completions/route | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/completions/route b/completions/route new file mode 100644 index 00000000..72079e23 --- /dev/null +++ b/completions/route @@ -0,0 +1,36 @@ +# Linux route(8) completion + +[[ $OSTYPE == *linux* ]] || return 1 + +_route() +{ + local cur prev words cword + _init_completion || return + + if [ "$prev" = dev ]; then + _available_interfaces + return 0 + fi + + # Remove already given options from completions + local opt found i + for opt in add del -host -net netmask metric mss window irtt reject mod \ + dyn reinstate dev default gw; do + found=false + for (( i=1; i < ${#words[@]}-1; i++ )); do + [ "${words[i]}" = "$opt" ] && found=true && break + done + $found || COMPREPLY[${#COMPREPLY[@]}]="$opt" + done + + COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) +} && +complete -F _route route + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh |