summaryrefslogtreecommitdiffstats
path: root/completions/alias
blob: 92211d839ef1b616b22e062287d902370e0ea26e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# bash alias completion                                    -*- shell-script -*-

_alias()
{
    local cur prev words cword
    _init_completion -n = || return

    case ${words[@]} in
        *[^=])
            COMPREPLY=($(compgen -A alias -- "$cur"))
            ;;
        *=)
            COMPREPLY=("$(alias ${cur%=} 2>/dev/null | command sed \
                -e 's|^alias '"$cur"'\(.*\)$|\1|')")
            ;;
    esac
} &&
    complete -F _alias -o nospace alias

# ex: filetype=sh