Zsh Mailing List Archive
Messages sorted by:
Re: s/pattern/pattern/g on the commandline ?
- X-seq: zsh-users 16798
- From: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- To: <zsh-users@xxxxxxx>
- Subject: Re: s/pattern/pattern/g on the commandline ?
- Date: Mon, 27 Feb 2012 10:38:44 +0000
- In-reply-to: <20120225182450.GA31597@solfire>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: Cambridge Silicon Radio
- References: <20120225182450.GA31597@solfire>
On Sat, 25 Feb 2012 19:24:50 +0100
> Is there any way to submit commands like
> 's/<searched>/<replacement>/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.
# actually autoloaded
# bindkey KEY to new WIDGET, possibly implemented by optional FUNCTION.
# FUNCTION defaults to WIDGET and will be marked for autoload -Uz.
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 <pws@xxxxxxx> 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
Messages sorted by: