# lz4 completion -*- shell-script -*- proc _lz4 { local cur prev words cword _init_completion || return match $prev { with -b _filedir return } if [[ "$cur" == -* ]] { setglobal COMPREPLY = ''( $( compgen -W \ '$( _parse_help "$1" -h | sed -e "/#/d" ) -B{4..7} -i{1..9}' \ -- "$cur" ) ) return } local args word xspec="*.?(t)lz4" _count_args [[ $args -gt 2 ]] && return for word in [$(words[@])] { match $word { with -*[dt]* match $args { with 1 setglobal xspec = ""!"$xspec" with 2 [[ $word == *t* ]] && return } break with -z match $args { with 1 setglobal xspec = '' with 2 setglobal xspec = ""!"$xspec" } break } } _expand || return 0 local IFS=$'\n' compopt -o filenames setglobal COMPREPLY = ''( $( compgen -f -X "$xspec" -- "$cur" ) \ $( compgen -d -- "$cur" ) ) } && complete -F _lz4 lz4 lz4c # ex: ts=4 sw=4 et filetype=sh