oh-my-bash/plugins/sudo
2023-04-10 09:27:04 +09:00
..
README.md plugins: Add plugin "sudo" 2023-04-09 00:04:00 +09:00
sudo.plugin.sh plugins/sudo: Add toggle support (#434) 2023-04-10 09:27:04 +09:00

sudo

Easily prefix your current or previous commands with sudo by pressing esc twice.

To use it, add sudo to the plugins array in your bashrc file:

plugins=(... sudo)

Usage

Current typed commands

Say you have typed a long command and forgot to add sudo in front:

$ apt-get install build-essential

By pressing the esc key twice, you will have the same command with sudo prefixed without typing:

$ sudo apt-get install build-essential

Previous executed commands

Say you want to delete a system file and denied:

$ rm some-system-file.txt
-su: some-system-file.txt: Permission denied
$

By pressing the esc key twice, you will have the same command with sudo prefixed without typing:

$ rm some-system-file.txt
-su: some-system-file.txt: Permission denied
$ sudo rm some-system-file.txt
Password:
$

Credits

Inspired by ohmyzsh sudo plugin.