[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 2.0-89-g26991e1

Ville Skyttä ville.skytta at iki.fi
Sat Jan 12 16:03:51 UTC 2013


The following commit has been merged in the master branch:
commit 26991e1bf4270a95dfea537b7ea514a1130b65bd
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Jan 12 18:02:39 2013 +0200

    nc: New completion.

diff --git a/completions/Makefile.am b/completions/Makefile.am
index 20aaa32..7fabb72 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -217,6 +217,7 @@ bashcomp_DATA = a2x \
 		mutt \
 		mysql \
 		mysqladmin \
+		nc \
 		ncftp \
 		nethogs \
 		newgrp \
diff --git a/completions/nc b/completions/nc
new file mode 100644
index 0000000..055924c
--- /dev/null
+++ b/completions/nc
@@ -0,0 +1,48 @@
+# nc(1) completion                                         -*- shell-script -*-
+
+_nc()
+{
+    local cur prev words cword
+    _init_completion || return
+
+    case $prev in
+        -h|-I|-i|-O|-P|-p|-V|-w)
+            return
+            ;;
+        -s)
+            _ip_addresses
+            return
+            ;;
+        -T)
+            COMPREPLY=( $( compgen -W 'critical inetcontrol lowdelay netcontrol
+                throughput reliability ef af{11..43} cs{0..7}' -- "$cur" ) )
+            return
+            ;;
+        -X)
+            COMPREPLY=( $( compgen -W '4 5 connect' -- "$cur" ) )
+            return
+            ;;
+        -x)
+            _known_hosts_real "$cur"
+            return
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
+        return
+    fi
+
+    # Complete 1st non-option arg only
+    local i
+    for (( i=1; i < cword; i++ )); do
+        [[ ${words[i]} != -* && \
+            ${words[i-1]} != @(-I|-i|-O|-P|-p|-s|-T|-V|-w|-X|-x) ]] && \
+            return
+    done
+
+    _known_hosts_real "$cur"
+} &&
+complete -F _nc nc
+
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/test/completion/nc.exp b/test/completion/nc.exp
new file mode 100644
index 0000000..a5c06b2
--- /dev/null
+++ b/test/completion/nc.exp
@@ -0,0 +1 @@
+assert_source_completions nc
diff --git a/test/lib/completions/eog.exp b/test/lib/completions/nc.exp
similarity index 81%
copy from test/lib/completions/eog.exp
copy to test/lib/completions/nc.exp
index b708c56..84e6189 100644
--- a/test/lib/completions/eog.exp
+++ b/test/lib/completions/nc.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "eog "
+assert_complete_any "nc -"
 sync_after_int
 
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list