man bash
describes a very useful Event Designator
^string1^string2^
Quick substitution. Repeat the last command, replacing string1 with string2. Equivalent to ''!!:s/string1/string2/''
Is there a way to execute !!:gs/string1/string2/
when typing in @string1@string2@
on the command line to replace all occurrences in the previous command? (@
or any other designated character/string)
^string1^string2^:g&
See question Replace all occurrences of a word in the last command.
See Modifiers in History Expansion.
Shortly: no!
In fact, there may exist a way, using `trap "..." debug'...
Something like:
This is quick and dirty, there left an execution error, but I think: It may be a way to do it.
Edit 01
This is a little better, but history stay quite wrong:
But warn: I do this for fun, for playing with bash and to understand how it work... This is not intended to be used in effective final solution!!