zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/2] Run ssh in batch mode
@ 2008-10-13 17:19 Jörg Sommer
  2008-10-13 17:19 ` [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs Jörg Sommer
  0 siblings, 1 reply; 3+ messages in thread
From: Jörg Sommer @ 2008-10-13 17:19 UTC (permalink / raw)
  To: zsh-workers; +Cc: Jörg Sommer

To prevent ssh asks for the password or prompts for acknowledging the
fingerprint and messing up with standard input, start it with
-oBatchMode=yes.
---
 Completion/Unix/Command/_ssh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index c52b38c..293732c 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -10,7 +10,7 @@ _remote_files () {
     then rempat="${PREFIX%%[^./][^/]#}\*"
     else rempat="${(q)PREFIX%%[^./][^/]#}\*"
     fi
-    remfiles=(${(M)${(f)"$(_call_program files ssh $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"}%%[^/]#(|/)})
+    remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"}%%[^/]#(|/)})
     compset -P '*/'
     compset -S '/*' || suf='remote file'
 
-- 
1.6.0.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs
  2008-10-13 17:19 [PATCH 1/2] Run ssh in batch mode Jörg Sommer
@ 2008-10-13 17:19 ` Jörg Sommer
  2008-10-14  4:26   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Jörg Sommer @ 2008-10-13 17:19 UTC (permalink / raw)
  To: zsh-workers; +Cc: Jörg Sommer

This patches uses the function _multi_parts to simplify the code. This
has the drawbacks that:
• The completion description doesn't contain the file type anymore, i.e.
  you don't get the suffixes @, |, * and =.

• The directory separator / isn't automaticly removed from the end, if
  you insert a space.

With _multi_parts it's easier to do completion of abbreviated path like
/u/s/d/zsh. So do it.
---
 Completion/Unix/Command/_ssh |   27 +++++----------------------
 1 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index 293732c..1ad22f8 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -2,32 +2,15 @@
 
 _remote_files () {
   # There should be coloring based on all the different ls -F classifiers.
-  local expl rempat remfiles remdispf remdispd args suf ret=1
+  local expl rempat remfiles args
 
   if zstyle -T ":completion:${curcontext}:files" remote-access; then
     zparseopts -D -E -a args p: 1 2 4 6 F:
-    if [[ -z $QIPREFIX ]]
-    then rempat="${PREFIX%%[^./][^/]#}\*"
-    else rempat="${(q)PREFIX%%[^./][^/]#}\*"
-    fi
-    remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"}%%[^/]#(|/)})
-    compset -P '*/'
-    compset -S '/*' || suf='remote file'
-
-    remdispf=(${remfiles:#*/})
-    remdispd=(${(M)remfiles:#*/})
+    rempat="${(q)PREFIX//\//*/}\*"
+    [[ $PREFIX = (.|..|)/* ]] && rempat=${PREFIX%%/*}/${rempat#*/}
+    remfiles=(${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"%[*=@|]})
 
-    _tags files
-    while _tags; do
-      while _next_label files expl ${suf:-remote directory}; do
-        [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
-	    ${(q)remdispf%[*=@|]} && ret=0 
-	compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
-	    ${(q)remdispd%/} && ret=0
-      done
-      (( ret )) || return 0
-    done
-    return ret
+    _wanted files expl 'remote file' _multi_parts $@ -- / remfiles
   else
     _message -e remote-files 'remote file'
   fi
-- 
1.6.0.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs
  2008-10-13 17:19 ` [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs Jörg Sommer
@ 2008-10-14  4:26   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2008-10-14  4:26 UTC (permalink / raw)
  To: zsh-workers

On Oct 13,  7:19pm, Joerg wrote:
}
} This patches uses the function _multi_parts to simplify the code.

I'm not convinced that "simpler" here is equivalent to "correct."  At
the very least the user should get to decide whether he prefers to
know the file type and to have the suffix autoremoved, i.e., the old
behavior should be available via a zstyle.

For one thing, the old behavior was intended to minimize the amount
of useless data the remote system had to send.  There are things it
is "fast enough" to do on the local filesystem that it's too costly
to wait for when it has to be shipped across the network as text.

Also, if you're giving up on the file type suffix, you should remove
the "F" option from the "ls" command that's executed on the remote
system.  I think that's the source of the quoting issue for which
you sent a follow-up patch to _multi_parts; I'm also not sure that
the _multi_parts patch is correct when the pattern is NOT going to be
evaluated on the far end of an ssh.

} With _multi_parts it's easier to do completion of abbreviated path like
} /u/s/d/zsh. So do it.

This doesn't quite work, even if it's worth the overhead.  If I try,
for example:

% scp remote:/u/s/d<TAB>

I get as far as

% scp remote:/usr/s/d

(with cursor on the second slash), and at that point it all stops
working; I can only complete more if I first move the cursor to the
end of the word (to the right of "d") every time.  If I merely
insert an "h" to disambiguate /usr/sbin from /usr/share and hit TAB
with the cursor still on the second slash, I end up going from

% scp remote:/usr/sh/d

to

% scp remote:

_complete_debug says (in part):

: _remote_files:6:then; rempat='\*/usr\*/sh\*' 
: _remote_files:7:then; [[ /usr/sh == (.|..|)/* ]]
: _remote_files:7:then cmdand; rempat='/usr\*/sh\*' 
: _remote_files:8:then; remfiles=: _remote_files:8:then; remfiles=( /usr/share/ 
) 

The trailing "/d" has been lost because the of the cursor placement.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-14  4:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-13 17:19 [PATCH 1/2] Run ssh in batch mode Jörg Sommer
2008-10-13 17:19 ` [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs Jörg Sommer
2008-10-14  4:26   ` Bart Schaefer

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).