We all know !! but it's mostly just used to sudo !!
I find !$ (which is last argument of the last command) incredibly useful:
#make a directory and go to it
mkdir workspace
cd workspace
# OR even better
mkdir workspace
cd !$
# move then edit a file
mv ~/somefile.txt ~/renamed.txt
vim !$
# edited a file, now add it to git
vim awesome_code.c
git add !$
There's a whole slew of ! commands but !$ is one I use all the time.
Neat tips! thanks
Here's mine:
We all know
!!but it's mostly just used tosudo !!I find
!$(which is last argument of the last command) incredibly useful:There's a whole slew of
!commands but!$is one I use all the time.You can also use
esc+.instead of!$. I find more natural and useful if you need to fix a typo.Even better! Thanks
P.S. For posterity, all of these work just as well in zsh.
Funny
$_is the exact same as!$. There's always more to learn 😀.