From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6609 invoked by alias); 27 Feb 2012 10:41:10 -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: 16798 Received: (qmail 18537 invoked from network); 27 Feb 2012 10:41:08 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 27 Feb 2012 10:38:44 +0000 From: Peter Stephenson To: Subject: Re: s/pattern/pattern/g on the commandline ? Message-ID: <20120227103844.1de5405d@pwslap01u.europe.root.pri> In-Reply-To: <20120225182450.GA31597@solfire> References: <20120225182450.GA31597@solfire> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.101.10.170] X-Scanned-By: MailControl 7.6.6 (www.mailcontrol.com) on 10.71.0.143 On Sat, 25 Feb 2012 19:24:50 +0100 wrote: > Is there any way to submit commands like > 's///g' for being applied the whole commandline > in one go? Just as a postscript, it's worth noting the ZLE widgets replace-string (which can also be loaded under the names replace-pattern or replace-regexp) and replace-string-again. This allows you to do this interactively from the command line. See the zshcontrib manual page. I use # actually autoloaded zlewidget() { # bindkey KEY to new WIDGET, possibly implemented by optional FUNCTION. # FUNCTION defaults to WIDGET and will be marked for autoload -Uz. local key=$1 local widget=$2 local function=${3:-$2} autoload -Uz $function zle -N $widget $function bindkey $key $widget } zlewidget "\e%" replace-regexp replace-string zlewidget '\e&' replace-regexp-again replace-string-again (though in fact I don't tend to use \e& because (i) I rarely need to replace the same thing multiple times (ii) I can't remember what the last thing I replaced is anyway.) -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog