From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9233 invoked from network); 19 Mar 2002 17:23:21 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 19 Mar 2002 17:23:21 -0000 Received: (qmail 26738 invoked by alias); 19 Mar 2002 17:23:15 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16864 Received: (qmail 26725 invoked from network); 19 Mar 2002 17:23:14 -0000 X-VirusChecked: Checked Date: Tue, 19 Mar 2002 17:22:45 +0000 From: Oliver Kiddle To: zsh-workers@sunsite.dk Subject: PATCH: completing remote files for scp Message-ID: <20020319172245.GA4311@logica.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.27i Sender: Oliver Kiddle As far as I could tell, completion of files for scp only worked with full filenames starting from root. More often than not, I want to copy files from my home on the remote system so I use no initial slash. Trying to do this, I first get `./' inserted and then can't complete in subdirectories. I think this patch is right now. I find it all a bit easier by using compadd -P/-S. I've also changed the consecutive calls to _wanted with the same tag which isn't particularly efficient. Some of this can probably be transferred over to _rsync. Oliver Index: Completion/Unix/Command/_ssh =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v retrieving revision 1.9 diff -u -r1.9 _ssh --- Completion/Unix/Command/_ssh 5 Feb 2002 18:10:54 -0000 1.9 +++ Completion/Unix/Command/_ssh 19 Mar 2002 17:12:01 -0000 @@ -2,21 +2,28 @@ _remote_files () { # There should be coloring based on all the different ls -F classifiers. - local expl remfiles remdispf remdispd + local expl remfiles remdispf remdispd suf ret=1 if zstyle -T ":completion:${curcontext}:" remote-access; then - remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${${${words[CURRENT]#*:}:h}/\\/(#e)/}/\* 2>/dev/null)"}) + remfiles=(${(M)${(f)"$(ssh -a -x ${words[CURRENT]%%:*} ls -d1F ${PREFIX%%[^/]#}\* 2>/dev/null)"}%%[^/]##(|/)}) + compset -P '*/' + compset -S '/*' || suf='remote file' remdispf=(${remfiles:#*/}) remdispd=(${(M)remfiles:#*/}) - _wanted files expl 'remote files and directories' \ - compadd -d remdispf ${${remfiles:#*/}/[*=@|](#e)/} - - _wanted files expl 'remote files and directories' \ - compadd -S/ -d remdispd ${${(M)remfiles:#*/}/\\/(#e)/} + _tags files + while _tags; do + while _next_label files expl ${suf:-remote directory}; do + [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \ + ${remdispf%[*=@|]} && ret=0 + compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \ + ${remdispd%/} && ret=0 + done + (( ret )) || return 0 + done else - _message 'remote files' + _message 'remote file' fi } -- This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.