Add autoinstall for packages (vim-plug, starship, ...)

This commit is contained in:
Tobias Reisinger 2022-09-13 21:28:05 +02:00
parent e448e719e8
commit 866bbcae20
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
5 changed files with 57 additions and 101 deletions

View file

@ -1,47 +0,0 @@
# doas-zsh-plugin
Easily prefix your current or previous commands with `doas` by pressing <kbd>esc</kbd> twice
To use it, add the following to your zshrc:
```console
plugins=(doas)
```
## Usage
### Current typed commands
Say you have typed a long command and forgot to add `doas` in front:
```console
$ apt-get install build-essential
```
By pressing the <kbd>esc</kbd> key twice, you will have the same command with `doas` prefixed without typing:
```console
$ doas apt-get install build-essential
```
### Previous executed commands
Say you want to delete a system file and denied:
```console
$ rm some-system-file.txt
-su: some-system-file.txt: Permission denied
$
```
By pressing the <kbd>esc</kbd> key twice, you will have the same command with `doas` prefixed without typing:
```console
$ rm some-system-file.txt
-su: some-system-file.txt: Permission denied
$ doas rm some-system-file.txt
Password:
$
```
Plugin inspired by sudo plugin by [Dongweiming](https://github.com/dongweiming)

View file

@ -1,32 +0,0 @@
# ------------------------------------------------------------------------------
# Description
# -----------
#
# doas will be inserted before the command
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Anatoly <akopyl@radner.ru>
#
# ------------------------------------------------------------------------------
doas-command-line() {
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
if [[ $BUFFER == doas\ * ]]; then
if [[ ${#LBUFFER} -le 4 ]]; then
RBUFFER="${BUFFER#doas }"
LBUFFER=""
else
LBUFFER="${LBUFFER#doas }"
fi
else
LBUFFER="doas $LBUFFER"
fi
}
zle -N doas-command-line
# Defined shortcut keys: [Esc] [Esc]
bindkey -M emacs '\e\e' doas-command-line
bindkey -M vicmd '\e\e' doas-command-line
bindkey -M viins '\e\e' doas-command-line