PageRenderTime 151ms CodeModel.GetById 91ms app.highlight 5ms RepoModel.GetById 53ms app.codeStats 0ms

/bash_completion.d/apt-show-versions

http://github.com/brinkman83/bashrc
#! | 51 lines | 46 code | 5 blank | 0 comment | 0 complexity | fa1d3d49e31d9ec2a7620bda126f75d1 MD5 | raw file
 1#-*-shell-script-*-
 2
 3have apt-show-versions &&
 4_apt_show_versions()
 5{
 6    local cur prev opts
 7
 8    COMPREPLY=()
 9    cur="${COMP_WORDS[COMP_CWORD]}"
10    if [[ "$cur" == --*=* ]]
11    then
12        prev="${cur%=*}"
13        cur="${cur##*=}"
14    else
15        prev="${COMP_WORDS[COMP_CWORD-1]}"
16    fi
17
18    opts="-a --allversions -b --brief -h --help -i --initialize -ld --list-dir"
19    opts="$opts -nh --nohold -p --package -r --regex -stf --status-file"
20    opts="$opts -u --upgradeable -v --verbose"
21
22    # Look for options needing an argument.
23    # The used completion functions are defined in /etc/bash_completion.
24    case "$prev" in
25        -ld|--list-dir)
26            _filedir -d
27            return 0
28            ;;
29        -p|--package)
30            COMPREPLY=( $(_comp_dpkg_installed_packages $cur) )
31            return 0
32            ;;
33        -stf|--status-file)
34            _filedir
35            return 0
36            ;;
37        *)
38            ;;
39    esac
40
41    # Look for options without an argument.
42    if [[ "$cur" == -* ]]
43    then
44        COMPREPLY=( $(compgen -W "$opts" -- $cur) )
45        return 0
46    else
47        COMPREPLY=( $(_comp_dpkg_installed_packages $cur) )
48        return 0
49    fi
50}
51complete -F _apt_show_versions -o filenames apt-show-versions