# lz4 completion -*- shell-script -*- proc _lz4 { var 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 } var args = '', word = '', xspec = '"*.?(t)lz4'" _count_args [[ $args -gt 2 ]] && return for word in [$(words[@])] { match $word { with -*[dt]* match $args { with 1 set xspec = ""!"$xspec" with 2 [[ $word == *t* ]] && return } break with -z match $args { with 1 set xspec = '' with 2 set xspec = ""!"$xspec" } break } } _expand || return 0 var 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