diff options
Diffstat (limited to '')
-rw-r--r-- | completions/dot | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/completions/dot b/completions/dot index 8122229..dcb8436 100644 --- a/completions/dot +++ b/completions/dot @@ -1,9 +1,9 @@ # dot(1) completion -*- shell-script -*- -_dot() +_comp_cmd_dot() { - local cur prev words cword - _init_completion -n := || return + local cur prev words cword comp_args + _comp_initialize -n := -- "$@" || return [[ $prev == -[V?] ]] && return @@ -12,34 +12,35 @@ _dot() return ;; -T*) - local langs=($("$1" -TNON_EXISTENT 2>&1 | - command sed -ne 's/.*one of://p')) - COMPREPLY=($(compgen -P -T -W '${langs[@]}' -- "${cur#-T}")) + # generate langs + _comp_compgen -c "${cur#-T}" split -P "-T" -- "$( + "$1" -TNON_EXISTENT 2>&1 | command sed -ne 's/.*one of://p' + )" return ;; -K*) - local layouts=($("$1" -KNON_EXISTENT 2>&1 | - command sed -ne 's/.*one of://p')) - COMPREPLY=($(compgen -P -K -W '${layouts[@]}' -- "${cur#-K}")) + # generate layouts + _comp_compgen -c "${cur#-K}" split -P "-K" -- "$( + "$1" -KNON_EXISTENT 2>&1 | command sed -ne 's/.*one of://p' + )" return ;; -o*) - cur=${cur#-o} - _filedir - COMPREPLY=($(compgen -P -o -W '${COMPREPLY[@]}' -- "$cur")) + _comp_compgen -c "${cur#-o}" filedir && + COMPREPLY=("${COMPREPLY[@]/#/-o}") return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n - -n1 -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?' -- "$cur")) + _comp_compgen -- -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n -n1 + -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?' [[ ${COMPREPLY-} == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace return fi - _filedir dot + _comp_compgen_filedir '@(gv|dot)' } && - complete -F _dot dot + complete -F _comp_cmd_dot dot # ex: filetype=sh |