From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1203 invoked by alias); 14 Mar 2013 12:17:43 -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: X-Seq: 17696 Received: (qmail 8490 invoked from network); 14 Mar 2013 12:17:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.210.172 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=SmcalKHFZum7EaKqgl9xaZmhza871gmI+AvJ6uqCQBc=; b=qkmf6V+Rm1lJpc9GmlIZ6leaBCVfye+8Ssql92aOxt/Zx/rvQL2L4d0Q1wveECxSzX KCTHvbBvdIq9EfKBsnJvSJhyNjT6fTJqS6/XwQOBmPk0Toe9stzaLwPozAtzGRlCW6gM Lxyaw4kz8SuYL9AproktJCXT8P3+lb3EbxOBCobJtc4FNItLssuykuAI0VjbBwN/AmO1 7DAKGRdWTdVstRY6QwUWzZjceprTeBm7w4YEHpt+t969AWMhkgZRnX1nLRX9/YWxU6RS LICy4I0KR5f7x3YTp6kI9BqGCzXdv6MeUKAH3+hVUpJnVTIlF3u6JFyBzEMGTQHxaf8S 2xJg== MIME-Version: 1.0 X-Received: by 10.50.151.179 with SMTP id ur19mr19716281igb.79.1363263449796; Thu, 14 Mar 2013 05:17:29 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 Mar 2013 13:17:29 +0100 Message-ID: Subject: Re: searching words in history similar to insert-last-word From: Mikael Magnusson To: zsh-users@zsh.org Cc: Dominik Vogt Content-Type: text/plain; charset=UTF-8 On 14 March 2013 13:06, Dominik Vogt wrote: > > Hi folks, > > I'm looking for a way to complete the last word I'm typing on the command > line by doing a history search. With Alt-. (insert-last-word) I can browse > through the last words of the previous lines, but I'm looking for something > more clever. My use case is this: > > I'm copying files to remote machines with scp, e.g. > > $ scp foo user@machine1.domain: > $ scp bar baz .* user@machine2.domain: > > I'd like to be able to simplify this by being able to type > > $ scp xyz user@ > > to yield > > $ scp xyz user@machine1.domain: > > When I press repeatedly, zsh should replace the last word on the > line with words from the history that begin with "user@". The function > name might be something like "beginning-search-up". Some extra features > or options would be: > > 1. Ignore the first word of each line but look through all other words > on each history line. > 2. (If the word that is to be completed is the first word on the line, > only consider the first word of all history lines.) > 3. Allow searching in the other direction with . alt-/ (_history-complete-older) > And as a related but seperate issue: > > How can I make a function that works like insert-last-word but works in the > opposite direction (insert-next-word). This would of course only be > usefull if I use insert-last-word first. _insert_next_word () { zle .insert-last-word 1 -1 } zle -N insert-next-word _insert_next_word -- Mikael Magnusson