Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: s/pattern/pattern/g on the commandline ?



On Feb 25,  7:46pm, Moritz Bunkus wrote:
}
} while we're at it: is there a way to do history expansion without
} actually submitting the modified entry?

I kept waiting for someone to mention this, but no one has yet ...

14.1.4 Modifiers
----------------

p
     Print the new command but do not execute it.  Only works with
     history expansion.

You can stack modifiers, so

	!!:p:gs/what/ever
or
	!!:gs/what/ever/:p

will both work. Note you need the trailing slash in the second case.
Other delimiters work for s/// -- you can even use a colon, so

	!:2:s:what:ever::p

means to take the second word of the previous command, change "what"
to "ever" in that word, and then display the result (and enter it
into the history list) without actually executing it.



Messages sorted by: Reverse Date, Date, Thread, Author