2 ms·
Bringing this on a small tangent, but I've never been comfortable with 'sudo !!' and I can't really articulate why aside from wanting to be as explicit as possi
by philjr 9y ago
Bringing this on a small tangent, but I've never been comfortable with 'sudo !!' and I can't really articulate why aside from wanting to be as explicit as possible.
<up>, <ctrl-a>, type sudo and enter is nearly as quick and much more explicit for me.
- leppr 9y agoAlso <ctrl-p> instead of <up> for extra touchtype points.
- scardine 9y agoIf you are a long time "vi" user, put `set -o vi` in "~/.bashrc": the sequence to issue the previous command with sudo prepended will be <esc>0isudo<enter>, probably something that is in your muscle memory already.
- sevensor 9y agoWhile I'm a very long time vi user, and I'm completely at home with the keybindings, I could never get into using "set -o vi". For me it falls into the uncanny valley of being quite like vi while not actually being vi.
- cromo 9y agoMy zsh is set up (don't know if this is a default or not; I'm using Oh My Zsh) to not run the command if you use any history expansions in a command, instead it'll give you a new prompt line with the substitutions already filled in. That way you can check that the command is correct before running it.
- stevenspasbo 9y agoBoth bash and zsh have the option histverify that will expand the !! like so: > echo "Test" > sudo !!<enter> > sudo echo "Test" You can then modify the command if you want to.