zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Andy Spiegl <zsh.Andy@spiegl.de>, zsh-users@sunsite.auc.dk
Subject: Re: Completion
Date: Tue, 22 Feb 2000 18:01:04 +0000	[thread overview]
Message-ID: <1000222180104.ZM10654@candle.brasslantern.com> (raw)
In-Reply-To: <20000222152437.A21283@br-online.de>

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


  reply	other threads:[~2000-02-22 18:01 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-22 11:36 Completion Sven Wischnowsky
2000-02-22 14:24 ` Completion Andy Spiegl
2000-02-22 18:01   ` Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-12-10 23:15 completion Ray Andrews
2014-12-10 23:31 ` completion Lawrence Velázquez
2014-12-11  0:34 ` completion Oliver Kiddle
2014-12-11  1:17   ` completion Ray Andrews
2014-12-11  5:44     ` completion Bart Schaefer
2014-12-11 16:40       ` completion Ray Andrews
2014-12-11 17:28         ` completion Bart Schaefer
2014-12-11 19:34           ` completion Ray Andrews
2015-01-07 15:01             ` completion Vincent Lefevre
2015-01-07 15:28               ` completion Peter Stephenson
2015-01-07 16:58                 ` completion Mikael Magnusson
2015-01-07 17:06                   ` completion Peter Stephenson
2015-01-07 18:33                   ` completion Ray Andrews
     [not found]                     ` <CAH+w=7Z_B2ghc21QgHxA8FEV7W8uQnjEwtPqK3tL-kjPihjicA@mail.gmail.com>
2015-01-07 19:54                       ` completion Bart Schaefer
2015-01-07 18:48               ` completion Bart Schaefer
2015-01-07 19:24                 ` completion Ray Andrews
2015-01-07 19:33                   ` completion Lawrence Velázquez
2015-01-07 20:06                     ` completion Ray Andrews
2015-01-07 19:51                   ` completion Bart Schaefer
2015-01-07 20:15                     ` completion Ray Andrews
2015-01-07 20:42                     ` completion Bart Schaefer
2015-01-07 23:00                       ` completion Ray Andrews
2015-01-08  5:09                         ` completion Bart Schaefer
2015-01-08  8:31                         ` completion Bart Schaefer
2015-01-08 16:52                           ` completion Ray Andrews
2015-01-08  0:43                 ` completion Vincent Lefevre
2015-01-08  0:57                   ` completion ZyX
2015-01-08  1:15                     ` completion Vincent Lefevre
2015-01-08  6:03                       ` completion Bart Schaefer
2015-01-08  5:26                   ` completion Bart Schaefer
2015-01-08 12:36                     ` completion Vincent Lefevre
2015-01-10  2:12                       ` completion Bart Schaefer
2015-01-12  9:09                         ` completion Vincent Lefevre
2015-01-12 16:43                           ` completion Bart Schaefer
2015-01-13 16:03                             ` completion Vincent Lefevre
2015-01-14  2:56                               ` completion Bart Schaefer
2015-01-08 17:12                     ` completion Ray Andrews
2015-01-09  9:37                       ` completion Vincent Lefevre
2015-01-10  5:33                       ` completion Bart Schaefer
2012-12-03 17:44 completion Ray Andrews
2012-12-03 18:31 ` completion Ray Andrews
2007-05-15 15:27 Completion Anonymous bin ich
2007-05-15 16:23 ` Completion Peter Stephenson
2006-02-20 12:54 Completion Etienne Chové
2006-02-20 18:51 ` Completion Clint Adams
2006-02-20 19:47   ` Completion Etienne Chové
2003-12-22 23:15 Completion Seth Kurtzberg
2000-02-22 14:58 Completion Sven Wischnowsky
2000-02-22 14:47 Completion Sven Wischnowsky
2000-02-22 15:01 ` Completion Andy Spiegl
2000-02-15  8:42 Completion Claus Alboege
2000-02-21 22:20 ` Completion Bart Schaefer
2000-02-22 10:37   ` Completion Andy Spiegl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1000222180104.ZM10654@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-users@sunsite.auc.dk \
    --cc=zsh.Andy@spiegl.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).