PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion.d/gzip

http://github.com/brinkman83/bashrc
#! | 48 lines | 40 code | 8 blank | 0 comment | 0 complexity | 7a1f649b0fbb0ca6c135fbe0f93fa535 MD5 | raw file
 1# bash completion for gzip
 2
 3have gzip &&
 4_gzip()
 5{
 6    local cur prev xspec helpopts
 7
 8    COMPREPLY=()
 9    cur=`_get_cword`
10    prev=${COMP_WORDS[COMP_CWORD-1]}
11    helpopts=`_parse_help gzip`
12
13    if [[ "$cur" == -* ]]; then
14        COMPREPLY=( $( compgen -W "$helpopts -2 -3 -4 -5 -6 -7 -8" -- "$cur" ) )
15        return 0
16    fi
17
18    local IFS=$'\t\n'
19
20    xspec="*.?(t)gz"
21    if [[ "$prev" == --* ]]; then
22        [[ "$prev" == --decompress || \
23            "$prev" == --list || \
24            "$prev" == --test ]] && xspec="!"$xspec
25        [[ "$prev" == --force ]] && xspec=
26    elif [[ "$prev" == -* ]]; then
27        [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
28        [[ "$prev" == -*f* ]] && xspec=
29    elif [ "$prev" = '>' -o "$prev" = '>>' ]; then
30        xspec=
31    elif [ "$prev" = '<' ]; then
32        xspec=
33    fi
34
35    _expand || return 0
36
37    COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
38        $( compgen -d -- "$cur" ) )
39} &&
40complete -F _gzip $filenames gzip
41
42# Local variables:
43# mode: shell-script
44# sh-basic-offset: 4
45# sh-indent-comment: t
46# indent-tabs-mode: nil
47# End:
48# ex: ts=4 sw=4 et filetype=sh