Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ssh compctl



Bek Oberin wrote:
> 
> I want to get ssh to complete either user@host or host.  I've figured
> out the former, with much rtfm'ing, but not the latter ... how can I
> give it alternates?

You're supposed to be able to do it with `+', as follows:

compctl -k users -S @ -x 'n[1,@]' -k hosts -- + -k hosts ssh

Maybe the section in the FAQ is clearer about alternatives than the manual,
but maybe not.

The new completion (Completion/User/_rlogin) should probably do this better
too.

--- Completion/User/_rlogin~	Wed Jul 14 13:57:32 1999
+++ Completion/User/_rlogin	Mon Jul 19 13:42:54 1999
@@ -1,9 +1,15 @@
 #compdef rlogin rsh ssh
 
-if [[ CURRENT -eq 2 ]]; then
-  _hosts
+if [[ CURRENT -eq 2 ]];
+  if compset -P 1 '*@'; then
+   _hosts
+  else
+    local nm=${compstate[nmatches]}
+    _hosts
+    [[ nm -eq compstate[nmatches] ]] && compgen -S @ -u
+  fi
 elif [[ CURRENT -eq 3 ]]; then
   compadd - -l
 else
-  compgen -u
+  compgen -S @ -u
 fi


-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author