diff options
Diffstat (limited to 'completions/aspell')
-rw-r--r-- | completions/aspell | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/completions/aspell b/completions/aspell index e080a07..89dae17 100644 --- a/completions/aspell +++ b/completions/aspell @@ -1,65 +1,66 @@ # bash completion for aspell -*- shell-script -*- -_aspell_dictionary() +_comp_cmd_aspell__dictionary() { - local datadir aspell=${1:-aspell} - datadir=$($aspell config data-dir 2>/dev/null || echo /usr/lib/aspell) + local datadir aspell=$1 + datadir=$("$aspell" config data-dir 2>/dev/null || echo /usr/lib/aspell) # First, get aliases (dicts dump does not list them) - COMPREPLY=($(printf '%s\n' $datadir/*.alias)) - COMPREPLY=("${COMPREPLY[@]%.alias}") - COMPREPLY=("${COMPREPLY[@]#$datadir/}") + if _comp_expand_glob COMPREPLY '"$datadir"/*.alias'; then + COMPREPLY=("${COMPREPLY[@]%.alias}") + COMPREPLY=("${COMPREPLY[@]#$datadir/}") + fi # Then, add the canonical dicts - COMPREPLY+=($($aspell dicts 2>/dev/null)) - COMPREPLY=($(compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur")) + _comp_split -a COMPREPLY "$("$aspell" dicts 2>/dev/null)" + ((${#COMPREPLY[@]})) && + _comp_compgen -- -X '\*' -W '"${COMPREPLY[@]}"' } -_aspell() +_comp_cmd_aspell() { - local cur prev words cword split - _init_completion -s || return + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return case $prev in -c | -p | check | --conf | --personal | --repl | --per-conf) - _filedir + _comp_compgen_filedir return ;; --conf-dir | --data-dir | --dict-dir | --home-dir | --local-data-dir | --prefix) - _filedir -d + _comp_compgen_filedir -d return ;; dump | create | merge) - COMPREPLY=($(compgen -W 'master personal repl' -- "$cur")) + _comp_compgen -- -W 'master personal repl' return ;; --mode) - COMPREPLY=($(compgen -W "$($1 modes 2>/dev/null | - awk '{ print $1 }')" -- "$cur")) + _comp_compgen_split -- "$("$1" modes 2>/dev/null | + _comp_awk '{ print $1 }')" return ;; --sug-mode) - COMPREPLY=($(compgen -W 'ultra fast normal bad-speller' \ - -- "$cur")) + _comp_compgen -- -W 'ultra fast normal bad-speller' return ;; --keymapping) - COMPREPLY=($(compgen -W 'aspell ispell' -- "$cur")) + _comp_compgen -- -W 'aspell ispell' return ;; -d | --master) - _aspell_dictionary "$1" + _comp_cmd_aspell__dictionary "$1" return ;; --add-filter | --rem-filter) - COMPREPLY=($(compgen -W "$($1 filters 2>/dev/null | - awk '{ print $1 }')" -- "$cur")) + _comp_compgen_split -- "$("$1" filters 2>/dev/null | + _comp_awk '{ print $1 }')" return ;; esac - $split && return + [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= + _comp_compgen -- -W '--conf= --conf-dir= --data-dir= --dict-dir= --encoding= --add-filter= --rem-filter= --mode= --add-extra-dicts= --rem-extra-dicts= --home-dir= --ignore= --ignore-accents --dont-ignore-accents --ignore-case --dont-ignore-case @@ -76,13 +77,13 @@ _aspell() --add-tex-command= --rem-tex-command= --tex-check-comments --dont-tex-check-comments --add-tex-extension --rem-tex-extension --add-sgml-check= --rem-sgml-check= --add-sgml-extension - --rem-sgml-extension' -- "$cur")) + --rem-sgml-extension' [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=($(compgen -W 'usage help check pipe list config soundslike - filter version dump create merge' -- "$cur")) + _comp_compgen -- -W 'usage help check pipe list config soundslike + filter version dump create merge' fi } && - complete -F _aspell aspell + complete -F _comp_cmd_aspell aspell # ex: filetype=sh |