Forgot to add sudo? Don't panic, you won't need to toggle previous command with arrow keys and edit, instead you can use
!! in shell provided that the shell you are using has csh-like history substitution(bash, zsh, tsh). To run previous command you can try following command in shell
There are many options related with
||Repeat previous command|
||Repeat command n|
||Repeat n-th-to-last command|
||Repeat last command beginning with str|
||Repeat last command containing str|
||Repeat the current command line typed so far|
!! or !-n etc. will not auto-expand until you execute them, you can use magic space to bind space key to expand them, to do that:
bindkey " " magic-space
above command will work for tcsh, zsh, if you are using bash then run following command instead of above command
you may want to add above command to ~/.shellnamerc file like zshrc, bashrc.
If you are using oh-my-zsh then you can add sudo to plugins in .zshrc file and just press escape key twice to insert sudo before a command.
blog comments powered by Disqus