doas-zsh-plugin
June 26, 2024 ยท View on GitHub
Easily prefix your current or previous commands with doas by pressing esc twice
This is fork of OMZ's sudo plugin.
Installation
Use Antidote
Add the following line to your plugins file:
Senderman/doas-zsh-plugin
Configuration
By default, this plugin uses to add/remove doas command. If you need different command (e.g. sudo), set this command in SUDOBIN environment variable, e.g.
export SUDOBIN=sudo
Usage
Current typed commands
Say you have typed a long command and forgot to add doas in front:
$ apt-get install build-essential
By pressing the esc key twice, you will have the same command with doas prefixed without typing:
$ doas 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 doas prefixed without typing:
$ rm some-system-file.txt
-su: some-system-file.txt: Permission denied
$ doas rm some-system-file.txt
Password:
$
doas is already in the beginning of the line
Say you already have doas in the beginning of the line:
$ doas ls
To remove it, press esc key twice:
$ ls