zsh-users
 help / color / mirror / code / Atom feed
From: David Woodfall <dave@dawoodfall.net>
To: zsh-users@zsh.org
Subject: Re: scp completion options
Date: Wed, 27 Jun 2018 11:13:12 +0100	[thread overview]
Message-ID: <20180627101312.GL11049@blackswan> (raw)
In-Reply-To: <20180627081516eucas1p200d804de13d1e5a4f7ea223ecb2d9c49~79k6870Wv1727517275eucas1p2j@eucas1p2.samsung.com>

On Wednesday 27 June 2018 09:15,
Peter Stephenson <p.stephenson@samsung.com> put forth the proposition:
> On Wed, 27 Jun 2018 00:06:54 +0100
> David Woodfall <dave@dawoodfall.net> wrote:
> > When I tab complete a scp command such as:
> >
> > scp somefile host:somefolder<tab>
> >
> > I will always get the current local directory as the first completion
> > option if it is any way similar to the name of the remote. Is there a
> > way to stop that behaviour and list remote directories first if I'm
> > scp'ing /to/ a host? In fact I will always have the local directory
> > listed whatever I do.
>
> Hmm... you *should* be able to do something like what's below (which is
> rather simplistic, as a demo).  The idea is: if you're on the third word
> or after, and the second word didn't have a ":" (so is assumed to be a
> local file), then only complete remotely.
>
> But actually I don't see how to get this to work in the case you're
> talking about (hence the question marks), because the tag for remote
> files is just 'files' so will allow it to complete local files.  This
> looks to me like a mistake, and _remote_files should arrange for a
> different tag.
>
> I may be missing something, but if I'm not, changing _remote_files ought
> to be easy.  There may also be other ways of limiting completion, but
> the point remains.
>
>
> scp_comp_helper() {
>   if [[ CURRENT -gt 2 && $words[2] != *:* && ]]; then
>     # Complete remotely only...?
>     reply=('hosts ????')
>   else
>     reply=('hosts files')
>   fi
> }
> zstyle -e ':completion:*:complete:scp:*:' tag-order scp_comp_helper

That's giving me an error on the 'if' line:

custom:597: parse error near `;'

--

Convention organizer to Linus Torvalds: "You might like to come with us
to some licensed[1] place, and have some pizza."

Linus: "Oh, I did not know that you needed a license to eat pizza".

[1] Licenced - refers in Australia to a restaurant which has government
licence to sell liquor.
  -- Linus at a talk at the Melbourne University

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'


  reply	other threads:[~2018-06-27 10:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180626231957epcas4p275197b8b1b133496936cd1e2a59d15b6@epcas4p2.samsung.com>
2018-06-26 23:06 ` David Woodfall
2018-06-27  8:15   ` Peter Stephenson
2018-06-27 10:13     ` David Woodfall [this message]
2018-06-28  8:38       ` Peter Stephenson
2018-06-28 20:14         ` David Woodfall
2018-06-28 20:26           ` Bart Schaefer
2018-06-28 20:56             ` David Woodfall
2018-06-29  0:31               ` Bart Schaefer
2018-06-29  2:31                 ` David Woodfall
2018-08-20 14:51                 ` David Woodfall
     [not found]   ` <20180627091514.22955a04@camnpupstephen.cam.scsc.local>
2018-06-29  8:33     ` Peter Stephenson

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=20180627101312.GL11049@blackswan \
    --to=dave@dawoodfall.net \
    --cc=zsh-users@zsh.org \
    /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).