For the people who want to be extra careful when running commands with sudo, you can enable history expansion with the space key. Put this in .bashrc.
sudo
.bashrc
bind Space:magic-space
Now typing !!<space> will replace the !! with your last command.
!!<space>
!!
If you use zsh with oh-my-zsh this is enabled by default. If you're not using oh-my-zsh, you can enable it using.
bindkey ' ' magic-space
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For the people who want to be extra careful when running commands with
sudo
, you can enable history expansion with the space key. Put this in.bashrc
.Now typing
!!<space>
will replace the!!
with your last command.If you use zsh with oh-my-zsh this is enabled by default. If you're not using oh-my-zsh, you can enable it using.