!!history!319^searchString^replaceString^or
!!:s/searchString/replaceString/
or search the whole command instead of first occurrence
!!:gs/old/new/make a directory then move into it:
mkdir -p $HOME/temp/dir
cd !$
!$ is shorthand for "the last word from the previous command". If I wanted to pick the third word
out of the previous command, that would be: !!:3 (don't forget there is a zeroth word).
For example:
# Print first word (the command) of the last command
echo !!:0Easily re-run the last command that contains a certain word:
!?restart
!?tail
Press CTRL-R to search history with dynamic autocomplete