DEV Community

Discussion on: It's ok if you forget to use the sudo command

Collapse
 
vonheikemen profile image
Heiker

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.

bind Space:magic-space

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.

bindkey ' ' magic-space