From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10643 invoked by alias); 27 Jun 2018 10:13:19 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23509 Received: (qmail 78 invoked by uid 1010); 27 Jun 2018 10:13:19 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-7.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.71):SA:0(-1.9/5.0):. Processed in 1.896799 secs); 27 Jun 2018 10:13:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: dave@dawoodfall.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Originating-IP: [82.40.94.2] X-Authenticated-User: X-Spam: 0 X-Authority: v=2.3 cv=YrwhubQX c=1 sm=1 tr=0 a=EH02hVpzcg1gP5HQFHlsKw==:117 a=EH02hVpzcg1gP5HQFHlsKw==:17 a=IkcTkHD0fZMA:10 a=hD80L64hAAAA:8 a=a1Uoi5jeAAAA:8 a=6WIQ6eivl4PIeri_Q7cA:9 a=QEXdDO2ut3YA:10 a=b5GIbgGVya4qEPgWM5ed:22 Date: Wed, 27 Jun 2018 11:13:12 +0100 From: David Woodfall To: zsh-users@zsh.org Subject: Re: scp completion options Message-ID: <20180627101312.GL11049@blackswan> Mail-Followup-To: zsh-users@zsh.org References: <20180626230654.GK11049@blackswan> <20180627081516eucas1p200d804de13d1e5a4f7ea223ecb2d9c49~79k6870Wv1727517275eucas1p2j@eucas1p2.samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180627081516eucas1p200d804de13d1e5a4f7ea223ecb2d9c49~79k6870Wv1727517275eucas1p2j@eucas1p2.samsung.com> User-Agent: Mutt/1.10+32 (ef19f486) (2018-06-19) X-CMAE-Envelope: MS4wfLdiFAazJdox41RA/L2YrHG+GpXMjk+0rNHrOE0jHnF334xSqj+9JJDVYfCDLEMkOTm49kjwSnFnlw8Zb4V0VaDZiLFambo76c+tW0l1W3liPuVgcIVE 4nYm3bIPNy9XvGKVxNL1sRml9pSJ6hVXsx0= On Wednesday 27 June 2018 09:15, Peter Stephenson put forth the proposition: > On Wed, 27 Jun 2018 00:06:54 +0100 > David Woodfall wrote: > > When I tab complete a scp command such as: > > > > scp somefile host:somefolder > > > > 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 (____)// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'