PageRenderTime 62ms CodeModel.GetById 60ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion.d/xz

http://github.com/brinkman83/bashrc
#! | 103 lines | 88 code | 15 blank | 0 comment | 0 complexity | 925348ff196b3ed67eccd2c753163809 MD5 | raw file
  1# xz(1) completion
  2
  3have xz &&
  4_xz()
  5{
  6    COMPREPLY=()
  7    local cur=`_get_cword`
  8    local prev=${COMP_WORDS[COMP_CWORD-1]}
  9
 10    if [[ "$cur" == -* ]]; then
 11        COMPREPLY=( $( compgen -W '-z --compress -d --decompress \
 12            -t --test -l --list -k --keep -f --force -c --stdout \
 13            -S --suffix --files --files0 -F --format -C --check \
 14            -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -M --memory --lzma1 \
 15            --lzma2 --x86 --powerpc --ia64 --arm --armthumb \
 16            --sparc --delta -q --quiet -v --verbose -h --help \
 17            -H --long-help -V --version' -- "$cur" ) )
 18        return 0
 19    fi
 20
 21    local split=false
 22    _split_longopt && split=true
 23
 24    local xspec="*.@(xz|lzma)"
 25
 26    case "$prev" in
 27        -@(!(-*)[dlt]*|-decompress|-list|-test))
 28            xspec="!"$xspec
 29            ;;
 30        --files|--files0)
 31            _filedir
 32            return 0
 33            ;;
 34        -C|--check)
 35            COMPREPLY=( $( compgen -W 'crc32 crc64 sha256' -- "$cur" ) )
 36            return 0
 37            ;;
 38        -F|--format)
 39            COMPREPLY=( $( compgen -W 'auto xz lzma raw' -- "$cur" ) )
 40            return 0
 41            ;;
 42        -M|--memory|-S|--suffix|--delta|--lzma1|--lzma2)
 43            # argument required but no completions available
 44            return 0
 45            ;;
 46        -h|--help|-H|--long-help|-V|--version)
 47            # all other arguments are noop with these
 48            return 0
 49            ;;
 50    esac
 51
 52    $split && return 0
 53
 54    _expand || return 0
 55
 56    local IFS=$'\t\n'
 57    COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
 58        $( compgen -d -- "$cur" ) )
 59} &&
 60complete -F _xz $filenames xz
 61
 62# xzdec(1) completion
 63#
 64have xzdec &&
 65_xzdec()
 66{
 67    COMPREPLY=()
 68    local cur=`_get_cword`
 69    local prev=${COMP_WORDS[COMP_CWORD-1]}
 70
 71    if [[ "$cur" == -* ]]; then
 72        COMPREPLY=( $( compgen -W '-M --memory -h --help -V --version' \
 73            -- "$cur" ) )
 74        return 0
 75    fi
 76
 77    local split=false
 78    _split_longopt && split=true
 79
 80    case "$prev" in
 81        -M|--memory)
 82            # argument required but no completions available
 83            return 0
 84            ;;
 85        -h|--help|-V|--version)
 86            # all other arguments are noop with these
 87            return 0
 88            ;;
 89    esac
 90
 91    $split && return 0
 92
 93    _filedir xz # no lzma support here as of xz 4.999.8beta
 94} &&
 95complete -F _xzdec $filenames xzdec
 96
 97# Local variables:
 98# mode: shell-script
 99# sh-basic-offset: 4
100# sh-indent-comment: t
101# indent-tabs-mode: nil
102# End:
103# ex: ts=4 sw=4 et filetype=sh