Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: scp completion options
- X-seq: zsh-users 23508
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: scp completion options
- Date: Wed, 27 Jun 2018 09:15:14 +0100
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180627081518euoutp02813184bec999282bcb51a58d8fe52e0a~79k8bLggs1084210842euoutp02C
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1530087318; bh=wY+zkf9V6Wl1ad9v8A+b15f9AmRnUQAmgsEWA33UBo4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=TkzBUHhCeYuqcN5zmEAsAyvpH2pwTPjIIWN9IlikqSRGnu/srs/W6voIwwCuivp80 Hdzi/MoHgP0A0SzLbHDvAl+aTTeIfxrjMIQ8FzgIDIOQv1Jo8Cip9lBNOr08BoP5OJ DH7EHXUT5L1ny86Y/WJVvgCz6FtjuTnhVoOTCpH0=
- In-reply-to: <20180626230654.GK11049@blackswan>
- 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>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <CGME20180626231957epcas4p275197b8b1b133496936cd1e2a59d15b6@epcas4p2.samsung.com> <20180626230654.GK11049@blackswan>
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
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author