~apt-fast/apt-fast/apt-fast-ro

« back to all changes in this revision

Viewing changes to apt-fast.comp

  • Committer: Dominique Lasserre
  • Date: 2012-09-24 20:55:38 UTC
  • Revision ID: git-v1:78eb613270be93c862cb260e4024b8517d268ee4
Add zsh completion. Closes #40

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Debian apt-fast(8) completion.
2
 
# Copy of Ubuntu 10.04 _apt_get function from apt completion. Merged with 12.04
3
 
# changes but preserve compatibility. _apt_get function renamed to _apt_fast.
4
 
 
5
 
have apt-fast &&
6
 
_apt_fast()
7
 
{
8
 
    local cur prev special i
9
 
 
10
 
    COMPREPLY=()
11
 
    cur=`_get_cword`
12
 
    prev=${COMP_WORDS[COMP_CWORD-1]}
13
 
 
14
 
    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
15
 
        if [[ ${COMP_WORDS[i]} == @(install|remove|autoremove|purge|source|build-dep|changelog|download) ]]; then
16
 
            special=${COMP_WORDS[i]}
17
 
        fi
18
 
    done
19
 
 
20
 
    if [ -n "$special" ]; then
21
 
        case $special in
22
 
            remove|autoremove|purge)
23
 
                if [ -f /etc/debian_version ]; then
24
 
                    # Debian system
25
 
                    COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
26
 
                else
27
 
                    # assume RPM based
28
 
                    _rpm_installed_packages
29
 
                fi
30
 
                return 0
31
 
                ;;
32
 
            source)
33
 
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
34
 
                    2> /dev/null ) $( apt-cache dumpavail | \
35
 
                    command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
36
 
                return 0
37
 
                ;;
38
 
            *)
39
 
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
40
 
                    2> /dev/null ) )
41
 
                return 0
42
 
                ;;
43
 
        esac
44
 
    fi
45
 
 
46
 
    case "$prev" in
47
 
        -@(c|-config-file))
48
 
             _filedir
49
 
             return 0
50
 
             ;;
51
 
        -@(t|-target-release|-default-release))
52
 
             COMPREPLY=( $( apt-cache policy | \
53
 
                 command grep "release.o=Debian,a=$cur" | \
54
 
                 sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
55
 
             return 0
56
 
             ;;
57
 
    esac
58
 
 
59
 
    if [[ "$cur" == -* ]]; then
60
 
        COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y -u -t -b -c -o \
61
 
            --download-only --fix-broken --help --version --ignore-missing \
62
 
            --fix-missing --no-download --quiet --simulate --just-print \
63
 
            --dry-run --recon --no-act --yes --assume-yes --show-upgraded \
64
 
            --only-source --compile --build --ignore-hold --target-release \
65
 
            --no-upgrade --force-yes --print-uris --purge --reinstall \
66
 
            --list-cleanup --default-release --trivial-only --no-remove \
67
 
            --diff-only --no-install-recommends --tar-only --config-file \
68
 
            --option --auto-remove' -- "$cur" ) )
69
 
    else
70
 
        COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
71
 
            dist-upgrade install remove purge source build-dep \
72
 
            check download clean autoclean autoremove changelog' -- "$cur" ) )
73
 
    fi
74
 
 
75
 
    return 0
76
 
} &&
77
 
complete -F _apt_fast $filenames apt-fast
78
 
 
79
 
# Local variables:
80
 
# mode: shell-script
81
 
# sh-basic-offset: 4
82
 
# sh-indent-comment: t
83
 
# indent-tabs-mode: nil
84
 
# End:
85
 
# ex: ts=4 sw=4 et filetype=sh