[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 2.1-21-g42196ef

Ville Skyttä ville.skytta at iki.fi
Fri Jun 14 21:36:04 UTC 2013


The following commit has been merged in the master branch:
commit 5a9e8f219b847a6c99f294b4cc492e77a63a22f0
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Jun 15 00:34:08 2013 +0300

    7z: New completion.

diff --git a/completions/.gitignore b/completions/.gitignore
index 3b76ba4..3291090 100644
--- a/completions/.gitignore
+++ b/completions/.gitignore
@@ -1,3 +1,4 @@
+7za
 aclocal-1.1[0123]
 alpine
 alternatives
diff --git a/completions/7z b/completions/7z
new file mode 100644
index 0000000..a4b086c
--- /dev/null
+++ b/completions/7z
@@ -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
diff --git a/completions/Makefile.am b/completions/Makefile.am
index 0e604f0..899ef85 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -1,5 +1,6 @@
 bashcompdir = $(pkgdatadir)/completions
-bashcomp_DATA = a2x \
+bashcomp_DATA = 7z \
+		a2x \
 		abook \
 		aclocal \
 		acpi \
@@ -382,6 +383,7 @@ EXTRA_DIST = $(bashcomp_DATA) \
 	     _mock _modules _nmcli _subversion _udevadm _yum _yum-utils
 
 CLEANFILES = \
+	7za \
 	aclocal-1.10 \
 	aclocal-1.11 \
 	aclocal-1.12 \
@@ -576,6 +578,10 @@ CLEANFILES = \
 	ypcat
 
 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 \
 		rm -f $(targetdir)/$$file && \
 			$(LN_S) aclocal $(targetdir)/$$file ; \
diff --git a/test/completion/7z.exp b/test/completion/7z.exp
new file mode 100644
index 0000000..0796b7a
--- /dev/null
+++ b/test/completion/7z.exp
@@ -0,0 +1 @@
+assert_source_completions 7z
diff --git a/test/lib/completions/su.exp b/test/lib/completions/7z.exp
similarity index 81%
copy from test/lib/completions/su.exp
copy to test/lib/completions/7z.exp
index 55dd80d..08d6bf1 100644
--- a/test/lib/completions/su.exp
+++ b/test/lib/completions/7z.exp
@@ -9,9 +9,9 @@ proc teardown {} {
 
 
 setup
-assert_complete_any "su "
 
 
+assert_complete_any "7z "
 sync_after_int
 
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list