# bash completion for bzip2 -*- shell-script -*- proc _bzip2 { local 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" == -* ]] { local helpopts=$[ _parse_help $1] setglobal COMPREPLY = ''( $( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ -- "$cur" ) ) return 0 } local IFS=$'\n' xspec="*.bz2" if [[ "$prev" == --* ]] { [[ "$prev" == --@(decompress|list|test) ]] && setglobal xspec = ""!"$xspec" [[ "$prev" == --compress ]] && setglobal xspec = '' } elif [[ "$prev" == -* ]] { [[ "$prev" == -*[dt]* ]] && setglobal xspec = ""!"$xspec" [[ "$prev" == -*z* ]] && setglobal 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