3 Easily prefix your current or previous commands with `sudo` by pressing <kbd>esc</kbd> twice.
5 To use it, add `sudo` to the plugins array in your zshrc file:
13 ### Current typed commands
15 Say you have typed a long command and forgot to add `sudo` in front:
18 $ apt-get install build-essential
21 By pressing the <kbd>esc</kbd> key twice, you will have the same command with `sudo` prefixed without typing:
24 $ sudo apt-get install build-essential
27 The same happens for editing files with your default editor (defined in `$SUDO_EDITOR`, `$VISUAL` or `$EDITOR`, in that order):
29 If the editor defined were `vim`:
35 By pressing the <kbd>esc</kbd> key twice, you will have the same command with `sudo -e` instead of the editor, that would open that editor with root privileges:
41 ### Previous executed commands
43 Say you want to delete a system file and denied:
46 $ rm some-system-file.txt
47 -su: some-system-file.txt: Permission denied
51 By pressing the <kbd>esc</kbd> key twice, you will have the same command with `sudo` prefixed without typing:
54 $ rm some-system-file.txt
55 -su: some-system-file.txt: Permission denied
56 $ sudo rm some-system-file.txt
61 The same happens for file editing, as told before.
65 By default, the `sudo` plugin uses <kbd>Esc</kbd><kbd>Esc</kbd> as the trigger.
66 If you want to change it, you can use the `bindkey` command to bind it to a different key:
69 bindkey -M emacs '<seq>' sudo-command-line
70 bindkey -M vicmd '<seq>' sudo-command-line
71 bindkey -M viins '<seq>' sudo-command-line
74 where `<seq>` is the sequence you want to use. You can find the keyboard sequence
75 by running `cat` and pressing the keyboard combination you want to use.