PageRenderTime 33ms CodeModel.GetById 30ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion.d/dput

http://github.com/brinkman83/bashrc
#! | 48 lines | 40 code | 8 blank | 0 comment | 0 complexity | ce16d64e83be90e5bc4504556bc5988a MD5 | raw file
 1#-*- mode: shell-script;-*-
 2
 3# Debian GNU/Linux dput(1) completion
 4# Copyright 2002 Roland Mas <lolando@debian.org>
 5
 6have dput &&
 7_dput()
 8{
 9    local cur prev options paroptions special i delayed_options hosts
10    
11    COMPREPLY=()
12    cur=${COMP_WORDS[COMP_CWORD]}
13    prev=${COMP_WORDS[COMP_CWORD-1]}
14    options='-c --config -d --debug -D --dinstall -f --force -h --help \
15             -H --host-list -l --lintian -o --check-only -p --print \
16             -P --passive -s --simulate -u --unchecked -d --delayed \
17             -v --version -V --check-version'
18
19    hosts=$(
20	{
21	    grep "^\[.*\]" $HOME/.dput.cf 2> /dev/null | tr -d [] || /bin/true
22	    grep "^\[.*\]" /etc/dput.cf 2> /dev/null | tr -d [] || /bin/true
23	} | grep -v '^DEFAULT$' | sort -u)
24
25    paroptions="$options $hosts"
26
27    case $prev in
28	--delayed|-e)
29	    delayed_options='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15'
30	    COMPREPLY=( $( compgen -W "$delayed_options" | grep ^$cur ) )
31	    ;;
32	--config|-c)
33	    COMPREPLY=( $( compgen -o filenames -G "$cur*" ) )
34	    ;;
35	*)
36	    COMPREPLY=( $(
37		    compgen -G "${cur}*.changes"
38		    compgen -G "${cur}*.asc"
39		    compgen -G "${cur}*.sig"
40		    compgen -W "$paroptions" | grep "^$cur"
41		) )
42	    ;;
43    esac
44
45    return 0
46
47}
48[ "$have" ] && complete -F _dput -o filenames -o plusdirs dput