A zsh plugin to use Esc+S to prepend sudo to a command with vi keybindings.
some really long zsh command
Just remembered you'll have to sudo? Assuming you have vi keybindings, you can now hit Esc to go into command mode, and then Esc+S to prepend a sudo to your long command without losing your place.
Assuming you have oh-my-zsh, you can simply write
git clone git@github.com:robertzk/sudo.zsh.git ~/.oh-my-zsh/custom/plugins/sudo
echo "plugins+=(sudo)" >> ~/.zshrc
(Alternatively, you can place the sudo
plugin in the plugins=(...)
local in your ~/.zshrc
manually.)
Unfortunately, due to use of zle
(zsh line editor), this shell script will not work on bash terminal.