diff --git a/CHANGES b/CHANGES index ac9ced72..4e9595f2 100644 --- a/CHANGES +++ b/CHANGES @@ -5,7 +5,7 @@ bash-completion (2.x) [ Ville Skyttä ] * Activate hping2 completion also for hping and hping3. - * Add crontab completion. + * Add crontab and lrzip completions. * Add gif to mplayer filename completions (Alioth: #312512). * Add "short" tarball extensions to unxz, unlzma etc completions. diff --git a/Makefile.am b/Makefile.am index d34b0283..f83171ee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -75,6 +75,7 @@ bashcomp_DATA = contrib/abook \ contrib/links \ contrib/lintian \ contrib/lisp \ + contrib/lrzip \ contrib/lvm \ contrib/lzma \ contrib/lzop \ diff --git a/bash_completion b/bash_completion index 4c184067..2f604045 100644 --- a/bash_completion +++ b/bash_completion @@ -78,6 +78,7 @@ complete -f -X '!*.Z' uncompress # lzcmp, lzdiff intentionally not here, see Debian: #455510 complete -f -X '!*.@(tlz|lzma)' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma complete -f -X '!*.@(?(t)xz|tlz|lzma)' unxz xzcat +complete -f -X '!*.lrz' lrunzip complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' ee complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview diff --git a/contrib/lrzip b/contrib/lrzip new file mode 100644 index 00000000..e5848035 --- /dev/null +++ b/contrib/lrzip @@ -0,0 +1,63 @@ +# lrzip(1) completion + +have lrzip && +_lrzip() +{ + COMPREPLY=() + local cur prev + _get_comp_words_by_ref cur prev + + if [[ "$cur" == -* && $prev != -N ]]; then + COMPREPLY=( $( compgen -W '-w -d -o -O -S -f -D -q -L -n -l -b -g -M \ + -T -N -v -vv -V -h' -- "$cur" ) ) + return 0 + fi + + local xspec="*.lrz" + + case $prev in + -w|-S|-V|-h) + return 0 + ;; + -d) + xspec="!"$xspec + ;; + -o) + _filedir + return 0 + ;; + -O) + _filedir -d + return 0 + ;; + -L) + COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9' -- "$cur" ) ) + return 0 + ;; + -T) + COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9 10' -- "$cur" ) ) + return 0 + ;; + -N) + COMPREPLY=( $( compgen -W '-20 -19 -18 -17 -16 -15 -14 -13 -12 \ + -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 \ + 12 13 14 15 16 17 18 19' -- "$cur" ) ) + return 0 + ;; + esac + + _expand || return 0 + + local IFS=$'\t\n' + COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ + $( compgen -d -- "$cur" ) ) +} && +complete -F _lrzip -o filenames lrzip + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/test/completion/lrzip.exp b/test/completion/lrzip.exp new file mode 100644 index 00000000..60616f00 --- /dev/null +++ b/test/completion/lrzip.exp @@ -0,0 +1 @@ +assert_source_completions lrzip diff --git a/test/lib/completions/lrzip.exp b/test/lib/completions/lrzip.exp new file mode 100644 index 00000000..bcf26c12 --- /dev/null +++ b/test/lib/completions/lrzip.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "lrzip " + + +sync_after_int + + +teardown