# bash completion for bzip2 -*- shell-script -*- proc _bzip2 { var cur = '', prev = '', words = '', cword = '' _init_completion || return match $prev { with -b|-h|--help|-p return 0 with -n setglobal COMPREPLY = '( '$( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) return 0 } if [[ "$cur" == -* ]] { var helpopts = $[ _parse_help $1] setglobal COMPREPLY = '( '$( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ -- "$cur" ) ) return 0 } var IFS = '$'\n',' xspec = '"*.bz2'" if [[ "$prev" == --* ]] { [[ "$prev" == --@(decompress|list|test) ]] && set xspec = ""!"$xspec" [[ "$prev" == --compress ]] && set xspec = '' } elif [[ "$prev" == -* ]] { [[ "$prev" == -*[dt]* ]] && set xspec = ""!"$xspec" [[ "$prev" == -*z* ]] && set xspec = '' } _expand || return 0 compopt -o filenames setglobal COMPREPLY = '( '$( compgen -f -X "$xspec" -- "$cur" ) \ $( compgen -d -- "$cur" ) ) } && complete -F _bzip2 bzip2 pbzip2 lbzip2 # ex: ts=4 sw=4 et filetype=sh