Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: scp completion options
- X-seq: zsh-users 23509
- From: David Woodfall <dave@xxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: scp completion options
- Date: Wed, 27 Jun 2018 11:13:12 +0100
- In-reply-to: <20180627081516eucas1p200d804de13d1e5a4f7ea223ecb2d9c49~79k6870Wv1727517275eucas1p2j@eucas1p2.samsung.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20180626231957epcas4p275197b8b1b133496936cd1e2a59d15b6@epcas4p2.samsung.com> <20180626230654.GK11049@blackswan> <20180627081516eucas1p200d804de13d1e5a4f7ea223ecb2d9c49~79k6870Wv1727517275eucas1p2j@eucas1p2.samsung.com>
On Wednesday 27 June 2018 09:15,
Peter Stephenson <p.stephenson@xxxxxxxxxxx> put forth the proposition:
> On Wed, 27 Jun 2018 00:06:54 +0100
> David Woodfall <dave@xxxxxxxxxxxxxx> 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
(____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author