From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5944 invoked from network); 22 Feb 2000 18:01:40 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 Feb 2000 18:01:40 -0000 Received: (qmail 2842 invoked by alias); 22 Feb 2000 18:01:21 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2930 Received: (qmail 2834 invoked from network); 22 Feb 2000 18:01:20 -0000 From: "Bart Schaefer" Message-Id: <1000222180104.ZM10654@candle.brasslantern.com> Date: Tue, 22 Feb 2000 18:01:04 +0000 In-Reply-To: <20000222152437.A21283@br-online.de> Comments: In reply to Andy Spiegl "Re: Completion" (Feb 22, 3:24pm) References: <200002221136.MAA14730@beta.informatik.hu-berlin.de> <20000222152437.A21283@br-online.de> X-Mailer: Z-Mail (5.0.0 30July97) To: Andy Spiegl , zsh-users@sunsite.auc.dk Subject: Re: Completion MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Feb 22, 3:24pm, Andy Spiegl wrote: } Subject: Re: Completion } } Say I press TAB after this: } $ scp foo me@bar:/usr/local/_ } Then I would like to see the files and directories on the remote host "bar", } but what I see is the possible completions for my own host. (A day without a patch is like a day without sunshine. Hmm, we're having one of those here right now ...) The change to _ssh is pretty trival. A more complex _remote_files is left as an excercise for those with more free time to kill. Problems: (1) It doesn't know from ssh/ssh1/ssh2/scp/scp1/scp2/etc. But then neither do the rest of the ssh completions. (2) Menu completion, at least with auto-menu, appears to execute the remote command a second time to generate the menu. (Does this indicate a bug in the C code?) That makes it pretty slow for the first two TABs. (3) There's a remote (pun?) possibility that expansion could interfere when using expand-or-complete; this might work best with complete-word and the _expand completer. (4) Because names are listed with "echo" on the remote host, wildcards are expanded when generating the completion, even if your styles say not to; i.e. you get part of the effect of _expand, always. This could be fixed by using ${(q)words[CURRENT]#*:}\* in _remote_files, but then expansion won't work at all. I think it's OK this way, except possibly that: (5) Parameter references are expanded on the remote machine when creating the completions, but on the local machine when the command is executed. (6) "No match" is handled badly if e.g. the remote login shell is csh. Index: Completion/User/_ssh =================================================================== @@ -1,5 +1,11 @@ #compdef ssh slogin scp ssh-add ssh-agent ssh-keygen +_remote_files () { + # This is extremely simple-minded; could parse "ls -F" output to do + # colorings and LIST_TYPES and so on, but I'm just not that ambitious. + compadd $(ssh ${words[CURRENT]%:*} echo ${words[CURRENT]#*:}\*) +} + _ssh () { local curcontext="$curcontext" state lstate line ret=1 expl args tmp typeset -A opt_args @@ -172,7 +178,7 @@ return elif [[ -n "$state" ]]; then if compset -P '*:'; then - _files && ret=0 + _remote_files && ret=0 elif compset -P '*@'; then _wanted hosts expl host && _ssh_hosts -S: "$expl[@]" && ret=0 else -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com