about summary refs log tree commit diff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-11-14 12:12:03 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-11-14 12:12:03 +0000
commitb50e035a8aa57e7b1aa92d5c40afd45b08234f1f (patch)
tree01c009dbf739689b4f7937294dcd04910a1f1310 /Completion/Unix/Command
parent81fe83008e48ca286d359e6e30ee36fbd4b9fe68 (diff)
downloadzsh-b50e035a8aa57e7b1aa92d5c40afd45b08234f1f.tar.gz
zsh-b50e035a8aa57e7b1aa92d5c40afd45b08234f1f.tar.xz
zsh-b50e035a8aa57e7b1aa92d5c40afd45b08234f1f.zip
users/10979: ssh completion uses config file from -F if present
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_ssh11
1 files changed, 9 insertions, 2 deletions
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index f241c82c9..d31e60760 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -323,6 +323,8 @@ _ssh_users () {
 
 _ssh_hosts () {
   local -a config_hosts
+  local config
+  integer ind
 
   if [[ "$IPREFIX" == *@ ]]; then
     _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
@@ -330,7 +332,12 @@ _ssh_hosts () {
     _combination -s '[:@]' my-accounts users-hosts \
       ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
   fi
-  if [[ -r "$HOME/.ssh/config" ]]; then
+  if (( ind = ${words[(I)-F]} )); then
+    config=$words[ind+1]
+  else
+    config="$HOME/.ssh/config"
+  fi
+  if [[ -r $config ]]; then
     local IFS=$'\t ' key hosts host
     while read key hosts; do
       if [[ "$key" == (#i)host ]]; then
@@ -341,7 +348,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