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

« back to all changes in this revision

Viewing changes to completions/bash/apt-fast

  • Committer: Dominique Lasserre
  • Date: 2020-04-06 22:37:35 UTC
  • Revision ID: git-v1:90dcdee963ad116fad1aaf0af2133405789bf7d7
Inherit completions from apt-get. Closes #173

 * This makes apt-fast dependent on the apt-get completion provided
   from the shell.
   Bash: bash-completion
   Zsh:  zsh-common
   Fish: fish-common

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