about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-10-29 21:20:35 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-10-29 21:20:35 +0000
commit21a83f33a53d3acefb4365969a4fa903c0828399 (patch)
tree83141c9cdc127a9bc41c12b1f69fa3c8621131f5 /Completion
parent83c6e0c34ae9464304030a00221bcdac773c866a (diff)
downloadzsh-21a83f33a53d3acefb4365969a4fa903c0828399.tar.gz
zsh-21a83f33a53d3acefb4365969a4fa903c0828399.tar.xz
zsh-21a83f33a53d3acefb4365969a4fa903c0828399.zip
Merge of 22811/22812: utilize _bind_addresses in existing completion functions.
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_ssh31
-rw-r--r--Completion/Unix/Type/_bind_addresses15
2 files changed, 40 insertions, 6 deletions
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index bf695c4e2..c52b38c3e 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -54,7 +54,7 @@ _ssh () {
     _arguments -C -s \
       '(-A)-a[disable forwarding of authentication agent connection]' \
       '(-a)-A[enables forwarding of the authentication agent connection]' \
-      '(-P)-b+[specify interface to transmit on]:bind address' \
+      '(-P)-b+[specify interface to transmit on]:bind address:_bind_addresses' \
       '-D+[specify a dynamic port forwarding]:port' \
       '-e+[set escape character]:escape character (or `none'"'"'):' \
       '(-n)-f[go to background]' \
@@ -75,6 +75,9 @@ _ssh () {
       '-V[show version number]' \
       '(-X)-x[disable X11 forwarding]' \
       '(-x)-X[enable X11 forwarding]' \
+      '-M[master mode for connection sharing]' \
+      '-S:path to control socket:_files' \
+      '-O:multiplex control command:(check exit)' \
       '*-L[specify local port forwarding]:local port forwarding:->forward' \
       '*-R[specify remote port forwarding]:remote port forwarding:->forward' \
       ':remote host name:->userhost' \
@@ -214,6 +217,13 @@ _ssh () {
           _description files expl 'xauth program'
           _files "$expl[@]" -g '*(-*)' && ret=0
           ;;
+	*(#i)controlmaster*)
+	  _wanted values expl 'truthish value' compadd yes no auto autoask && ret=0
+	  ;;
+	*(#i)controlpath*)
+          _description files expl 'path to control socket'
+          _files "$expl[@]" && ret=0
+	  ;;
         esac
       else
         _wanted values expl 'configure file option' \
@@ -223,13 +233,14 @@ _ssh () {
 		ChallengeResponseAuthentication CheckHostIP \
 		Cipher Ciphers ClearAllForwardings Compression \
                 CompressionLevel ConnectionAttempts ConnectTimeout \
+		ControlMaster ControlPath \
 		DynamicForward EnableSSHKeysign \
 		EscapeChar FallBackToRsh ForwardAgent ForwardX11 \
 		ForwardX11Trusted \
                 GatewayPorts GlobalKnownHostsFile GSSAPIAuthentication \
 		GSSAPIDelegateCredentials HostbasedAuthentication \
 		HostKeyAlgorithms HostKeyAlias HostName IdentityFile \
-		IdentitiesOnly \
+		IdentitiesOnly KbdInteractiveDevices \
 		KeepAlive KerberosAuthentication KerberosTgtPassing \
 		LocalForward LogLevel MACs NoHostAuthenticationForLocalhost \
 		NumberOfPasswordPrompts PreferredAuthentications \
@@ -312,14 +323,22 @@ _ssh_users () {
 
 _ssh_hosts () {
   local -a config_hosts
+  local config
+  integer ind
 
+  # If users-hosts matches, we shouldn't complete anything else.
   if [[ "$IPREFIX" == *@ ]]; then
-    _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
+    _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@" && return
   else
     _combination -s '[:@]' my-accounts users-hosts \
-      ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
+      ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@" && return
+  fi
+  if (( ind = ${words[(I)-F]} )); then
+    config=${~words[ind+1]}
+  else
+    config="$HOME/.ssh/config"
   fi
-  if [[ -r "$HOME/.ssh/config" ]]; then
+  if [[ -r $config ]]; then
     local IFS=$'\t ' key hosts host
     while read key hosts; do
       if [[ "$key" == (#i)host ]]; then
@@ -330,7 +349,7 @@ _ssh_hosts () {
 	    esac
 	 done
       fi
-    done < "$HOME/.ssh/config"
+    done < "$config"
     if (( ${#config_hosts} )); then
       _wanted hosts expl 'remote host name' \
 	compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts
diff --git a/Completion/Unix/Type/_bind_addresses b/Completion/Unix/Type/_bind_addresses
new file mode 100644
index 000000000..606de3ffb
--- /dev/null
+++ b/Completion/Unix/Type/_bind_addresses
@@ -0,0 +1,15 @@
+#autoload
+
+local expl
+
+case $OSTYPE in
+  aix*) _hosts "$@" ;;
+  darwin*|freebsd*|dragonfly*) _hosts "$@" ;;
+  irix*) _hosts "$@" ;;
+  # Couldn't find anything special for linux except for /proc/net/dev
+  # Is there any proc file which gives the formatted ip?
+  linux*) ;&
+  *)
+    _wanted bind-addresses expl 'bind address' compadd "$@" - \
+      ${${${(M)${(f)"$(ifconfig -a)"}:#*addr:*}##*addr:}%% *}
+esac