Last Updated: January 06, 2019
·
706
· davefp

Forgot to Sudo? !! is your friend

Bash has a neat built in command for replaying the last command you typed:

> !!

Knowing this, you can do the following:

> make me a sandwich
What? Make it yourself.
> sudo !!
sudo make me a sandwich
Okay.

It also works wonders when you forget to bundle exec before you rake:

> rake db:migrate
barf due to wrong version of rake
> bundle exec !!
bundle exec rake db:migrate
success etc...

Picture

1 Response
Add your response

Zsh has the same command.

over 1 year ago ·