7z: New completion.

This commit is contained in:
Ville Skyttä 2013-06-15 00:34:08 +03:00
parent 3a3290ddcf
commit 5a9e8f219b
5 changed files with 91 additions and 1 deletions

View File

@ -1,3 +1,4 @@
7za
aclocal-1.1[0123] aclocal-1.1[0123]
alpine alpine
alternatives alternatives

64
completions/7z Normal file
View File

@ -0,0 +1,64 @@
# 7z(1) completion -*- shell-script -*-
_7z()
{
local cur prev words cword
_init_completion -n = || return
if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'a b d e l t u x' -- "$cur" ) )
return
fi
case $cur in
-mhe=*)
COMPREPLY=( $( compgen -W 'on off' -- "${cur#*=}" ) )
return
;;
-o*|-w?*)
compopt -o nospace -o filenames
COMPREPLY=( $( compgen -P${cur:0:2} -S/ -d -- "${cur:2}" ) )
return
;;
-r?*)
COMPREPLY=( $( compgen -P${cur:0:2} -W '- 0' -- "${cur:2}" ) )
return
;;
-scs*)
COMPREPLY=( $( compgen -P${cur:0:4} -W 'UTF-8 WIN DOS' \
-- "${cur:4}" ) )
return
;;
-ssc?*)
COMPREPLY=( $( compgen -P${cur:0:4} -W '-' -- "${cur:4}" ) )
return
;;
-t*)
COMPREPLY=( $( compgen -P${cur:0:2} -W '7z zip gzip bzip2 tar' \
-- "${cur:2}" ) )
return
;;
-a*|-i*|-m*|-p*|-u*|-v*|-x*)
return
;;
esac
if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '-ai -ax -bd -i -m -o -p -r -scs -sfx -si
-slt -so -ssc -t -u -v -w -x -y' -- "$cur" ) )
[[ $COMPREPLY == -@(bd|sfx|si|slt|so|ssc|[rwy]) ]] || compopt -o nospace
return
fi
local args
_count_args =
if [[ $args -eq 2 ]]; then
_filedir_xspec unzip
_filedir '@(7z|arj|bz2|cab|cpio|deb|gem|?(g)tar|?(t)[bg]z|tb?(z)2|rpm)'
else
_filedir
fi
} &&
complete -F _7z 7z 7za
# ex: ts=4 sw=4 et filetype=sh

View File

@ -1,5 +1,6 @@
bashcompdir = $(pkgdatadir)/completions bashcompdir = $(pkgdatadir)/completions
bashcomp_DATA = a2x \ bashcomp_DATA = 7z \
a2x \
abook \ abook \
aclocal \ aclocal \
acpi \ acpi \
@ -382,6 +383,7 @@ EXTRA_DIST = $(bashcomp_DATA) \
_mock _modules _nmcli _subversion _udevadm _yum _yum-utils _mock _modules _nmcli _subversion _udevadm _yum _yum-utils
CLEANFILES = \ CLEANFILES = \
7za \
aclocal-1.10 \ aclocal-1.10 \
aclocal-1.11 \ aclocal-1.11 \
aclocal-1.12 \ aclocal-1.12 \
@ -576,6 +578,10 @@ CLEANFILES = \
ypcat ypcat
symlinks: $(targetdir) $(DATA) symlinks: $(targetdir) $(DATA)
for file in 7za ; do \
rm -f $(targetdir)/$$file && \
$(LN_S) 7z $(targetdir)/$$file ; \
done
for file in aclocal-1.10 aclocal-1.11 aclocal-1.12 aclocal-1.13 ; do \ for file in aclocal-1.10 aclocal-1.11 aclocal-1.12 aclocal-1.13 ; do \
rm -f $(targetdir)/$$file && \ rm -f $(targetdir)/$$file && \
$(LN_S) aclocal $(targetdir)/$$file ; \ $(LN_S) aclocal $(targetdir)/$$file ; \

1
test/completion/7z.exp Normal file
View File

@ -0,0 +1 @@
assert_source_completions 7z

View File

@ -0,0 +1,18 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "7z "
sync_after_int
teardown