summaryrefslogtreecommitdiffstats
path: root/completions/hunspell
blob: 28cb7dfae4db03528f4c397c9470bbbdcf577c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# hunspell(1) completion                                   -*- shell-script -*-

_comp_cmd_hunspell()
{
    local cur prev words cword comp_args
    _comp_initialize -- "$@" || return

    case $prev in
        --help | --version | -vv | -[hPv])
            return
            ;;
        -d)
            local -a dicts
            if _comp_expand_glob dicts '/usr/share/hunspell/*.dic /usr/local/share/hunspell/*.dic'; then
                dicts=("${dicts[@]##*/}")
                dicts=("${dicts[@]%.dic}")
                _comp_compgen -- -W '"${dicts[@]}"'
            fi
            return
            ;;
        -i)
            _comp_compgen -x iconv charsets
            return
            ;;
        -p)
            _comp_compgen_filedir
            return
            ;;
    esac

    if [[ $cur == -* ]]; then
        _comp_compgen_help
        return
    fi

    _comp_compgen_filedir
} &&
    complete -F _comp_cmd_hunspell hunspell

# ex: filetype=sh