From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18567 invoked by alias); 26 Feb 2012 15:17:23 -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: 16794 Received: (qmail 16138 invoked from network); 26 Feb 2012 15:17:22 -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 _spf.google.com designates 74.125.82.171 as permitted sender) Received-SPF: pass (google.com: domain of arkanosis@gmail.com designates 10.180.99.65 as permitted sender) client-ip=10.180.99.65; Authentication-Results: mr.google.com; spf=pass (google.com: domain of arkanosis@gmail.com designates 10.180.99.65 as permitted sender) smtp.mail=arkanosis@gmail.com; dkim=pass header.i=arkanosis@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=1bbLGJEAtegAuVfNbHQstMdyHCOTZ1bTKKi1LWsKHjA=; b=KFF+PVm2onNPgxMwjKeG7180w+bSckJxP62dBJXF7eljuq6U+ImqOdGiJDOD4/zO9A dtYUc3lLRmqz7f7WDPM9BjQ9K+zTRQ1/w7sNu4jZZncHp6ACvHlm+lde7DQMg8WacpOq OysR4SqNsZakaWqYdO8Co8sC2bF8pzSgUnyNc= MIME-Version: 1.0 In-Reply-To: <20120226075234.GB3020@solfire> References: <20120225182450.GA31597@solfire> <20120226075234.GB3020@solfire> From: =?UTF-8?B?SsOpcsOpbWllIFJvcXVldA==?= Date: Sun, 26 Feb 2012 16:17:00 +0100 Message-ID: Subject: Re: s/pattern/pattern/g on the commandline ? To: meino.cramer@gmx.de Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, 2012/2/26 : > ...an additional question: > > Suppose I had entered such an ugly looooong commandline about two days > ago. I did not remember when it was and what the context was. > And: I have a very looong history file. > > I want to recycle that line and do the s//g-trick on it to get a shiny > new fresh commmandline for the next action. If the command in your long line is unusual (let's say =E2=80=9Cmakecoffee= =E2=80=9D), you could use: !makecoffee:gs// > When I press ^r I easily can find that line, it will > displayed instantly but without its numbering. In the moment the > commandline is displayed I loose the ability to do the s//g-trick. > > Is there a way to browse the commandlines like with ^r only to get its > numbering to apply the s//g-trick to the choosen line ? Hacking history-incremental-pattern-search-backward is an option, but that wouldn't be easy. Instead, you could use: fc -lm =E2=80=A6to list previous commands matching the pattern, with their numbers= . Also, what I do in non trivial cases, is either: - use edit-command-line as pointed out by Phil: you just have to ctrl+r the line you want and then edit it using a real text editor, or - use a custom widget to run sed (or awk, or perl, or=E2=80=A6) on the current line : you just have to ctrl+r the line you want then to use whatever key you've bound the widget to to run sed on it. If you put this in your .zshrc: function sed-line () { read-from-minibuffer 'Sed: ' if [[ -n $REPLY ]]; then BUFFER=3D`echo $BUFFER | sed $REPLY` fi } zle -N sed-line bindkey "^[e" sed-line =E2=80=A6 you can then use meta-e to run a sed command on the line currentl= y being edited in your shell. Best regards, --=20 J=C3=A9r=C3=A9mie