From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3522 invoked from network); 26 Sep 1999 15:38:15 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 26 Sep 1999 15:38:15 -0000 Received: (qmail 7077 invoked by alias); 26 Sep 1999 15:38:03 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8051 Received: (qmail 7070 invoked from network); 26 Sep 1999 15:38:02 -0000 Message-Id: <9909261502.AA30070@ibmth.df.unipi.it> To: zsh workers mailing list Subject: Re: PATCH: improvement to user@host completions In-Reply-To: "Adam Spiers"'s message of "Sun, 26 Sep 1999 15:17:23 DFT." <19990926151723.F1246@thelonious.new.ox.ac.uk> Date: Sun, 26 Sep 1999 17:02:33 +0200 From: Peter Stephenson Adam Spiers wrote: > This patch harnesses the power of Tanaka's _combination in _rlogin, _ssh > and other functions. > > The user should put something similar to the following in his .zshrc: > > ... > > and then a whole family of commands will then intelligently complete > (user, host) pairs, in both `-l user host' (where appropriate) and > `user@host' style. Currently the rlogin and ssh family are affected, > and also ytalk and finger. This is an excellent idea, but it could do with some documentation. Currently that just means comments in the appropriate functions. (Not all functions have them, of course, but here it's crucial that users know they're supposed to set some variables.) Ideally, the functions _ssh_users and _ssh_hosts should be tested for existence before they're defined so that users can define their own. There were some typos which I've fixed. However (long digresion), in the long run I'm hoping for some context-sensitive help. Something like _description would be used to add it. It would give a message something like this (I've assumed my suggestion for tags and locators, but it doesn't have to depend on that at all): % tar xvzf ^X^H Current completion context is _tar->tar-archive. _tar performs completion for the tar command, including GNU tar extension. Possible subcontexts are: option, tarfile, content, file Subcontext tar-archive completes a tar archive. By default this is a file ending in *.tar, although this can be modified by the GNU -z option to search for *.tar.gz. Tags used: glob: use specific pattern to find a file path: directory path to a file anyfile: use any file as default if glob tag fails. or in this case % ssh ^X^H Current completion context is _ssh->userhost. _ssh performs completion for ssh and related commands such as scp. Possible subcontexts are: option forward command userhost Subcontext userhost completes either hostnames, or user@host pairs. For this to work best the arrays my_accounts and other_accounts should be set; each contains entries in the form user:[host] where host defaults to the current host, or {user1,user2}:host for multiple users on the same host. You may also set _accounts for each specific such as ssh. Tags used: userat: complete username for the form user@host host: complete an Internet hostname. I've simplified this because in fact there is a separate function _tar_archive, and I haven't worked out how that fits in to this scheme. To remind you: my idea about tags (and Sven was no doubt thinking along similar lines) was that they could allow you to set priorities for completions, e.g. you could say you only wanted user@ to be completed if all the hosts failed. Then you could extend the tags to set priorities for my_accounts and other_accounts. There could also be an option so that typing ^D multiple times toggles between showing the completion list and showing the context-sensitive help. This is all Zukunftsmusik. > P.S. Why does cvs diff not put the full path in the +++ line for newly > added files? And why doesn't patch understand `Index:' ? Did you call cvs diff from the top level directory? I think patch only recognises `Index:' on the line immediately before the hunk it refers to. I don't know CVS well enough to tell you why it didn't happen. --- Completion/User/_users_on.c2 Sun Sep 26 15:47:42 1999 +++ Completion/User/_users_on Sun Sep 26 16:33:01 1999 @@ -1,9 +1,9 @@ -#autoload write +#compdef write local expl if which users >/dev/null; then - _description expl users logged on + _description expl 'users logged on' compadd "$@" "$expl[@]" - $(users) && return 0 else # Other methods of finding out users logged on should be added here -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy