Zsh rerun last command with search/replace
Heads up, you can rerun the last command with a replace in one swoop:
!!:s/find it/replace it/
That'll do the first match, but to replace all matches on the line:
!!:gs/gotta/replace them all/
If that's not short enough for you (this is UNIX command line after all), rerun last command and perform a replace on first match:
^find it^replace it
Oh, two more things...
it's stackable:
!!:s/find this/replace it/:s/find that/replace it too/
same thing works with variables:
echo ${PATH:gs/copenhas/YOU/}
Written by Sean Copenhaver
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#