summaryrefslogtreecommitdiff
blob: a182098f3c334c4ae5a6aa55a9d07d028e114742 (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
41
42
43
44
45
46
# Gentoo Linux Bash Shell Command Completion
#
# Copyright 1999-2013 Gentoo Authors
# Distributed under the terms of the GNU General Public License, v2 or later

source "@helpersdir@/gentoo-common.sh"

#
# ekeyword completion
#

_ekeyword()
{
    local cur portdir archl_s archl_u archl_r archl_m arch
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    portdir=$(_portdir)

    [[ -f ${portdir}/profiles/arch.list ]] || return 0

    for arch in all $(< ${portdir}/profiles/arch.list) ; do
        archl_m="${archl_m} -${arch}"
        archl_u="${archl_u} ~${arch}"
        archl_r="${archl_r} ^${arch}"
        archl_s="${archl_s}  ${arch}"
    done

    case ${cur} in
        -*)
            COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
            ;;
        ~*)
            COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
            ;;
        ^*)
            COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
            ;;
        *)
            COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
            _filedir 'ebuild'
            ;;
        esac
} &&
complete -o filenames -F _ekeyword ekeyword

# vim: ft=sh:et:ts=4:sw=4:tw=80