Add doas config stuff
This commit is contained in:
parent
b44c41f339
commit
3d17d60bc9
5 changed files with 97 additions and 6 deletions
|
@ -10,7 +10,7 @@ alias bfg='java -jar ~/tools/bfg-1.13.0.jar'
|
||||||
alias cp='cp -i'
|
alias cp='cp -i'
|
||||||
|
|
||||||
alias df='df -h'
|
alias df='df -h'
|
||||||
alias doas='doas --'
|
alias doas='doas -- '
|
||||||
alias dotfiles='.f'
|
alias dotfiles='.f'
|
||||||
alias dotfiles-mail='.fm'
|
alias dotfiles-mail='.fm'
|
||||||
alias du='du -h'
|
alias du='du -h'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Path to your oh-my-zsh installation.
|
# Path to your oh-my-zsh installation.
|
||||||
export ZSH="$HOME/.config/zsh/oh-my-zsh"
|
export ZSH="$ZDOTDIR/oh-my-zsh"
|
||||||
|
|
||||||
if [ ! -f "$ZSH/oh-my-zsh.sh" ]
|
if [ ! -f "$ZSH/oh-my-zsh.sh" ]
|
||||||
then
|
then
|
||||||
|
@ -65,7 +65,13 @@ DISABLE_AUTO_UPDATE="false"
|
||||||
# HIST_STAMPS="yyyy-mm-dd"
|
# HIST_STAMPS="yyyy-mm-dd"
|
||||||
|
|
||||||
# Would you like to use another custom folder than $ZSH/custom?
|
# Would you like to use another custom folder than $ZSH/custom?
|
||||||
# ZSH_CUSTOM=/path/to/new-custom-folder
|
ZSH_CUSTOM=$ZDOTDIR/custom
|
||||||
|
|
||||||
|
priv_plugin=sudo
|
||||||
|
if [ -x "$(command -v doas)" ]
|
||||||
|
then
|
||||||
|
priv_plugin=doas
|
||||||
|
fi
|
||||||
|
|
||||||
# Which plugins would you like to load?
|
# Which plugins would you like to load?
|
||||||
# Standard plugins can be found in $ZSH/plugins/
|
# Standard plugins can be found in $ZSH/plugins/
|
||||||
|
@ -83,8 +89,9 @@ plugins=(
|
||||||
jump
|
jump
|
||||||
kubectl
|
kubectl
|
||||||
safe-paste
|
safe-paste
|
||||||
sudo
|
|
||||||
vi-mode
|
vi-mode
|
||||||
|
|
||||||
|
$priv_plugin
|
||||||
)
|
)
|
||||||
|
|
||||||
source $ZSH/oh-my-zsh.sh
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
47
.config/zsh/custom/plugins/doas/README.md
Normal file
47
.config/zsh/custom/plugins/doas/README.md
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
# 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)
|
32
.config/zsh/custom/plugins/doas/doas.plugin.zsh
Normal file
32
.config/zsh/custom/plugins/doas/doas.plugin.zsh
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# 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
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/sh
|
#!/usr/bin/sh
|
||||||
|
|
||||||
yay -Syu
|
paru -Syu
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "UPDATE SUCCEDEED"
|
echo "UPDATE SUCCEDEED"
|
||||||
|
@ -13,7 +13,12 @@ fi
|
||||||
echo "==================================================================="
|
echo "==================================================================="
|
||||||
|
|
||||||
|
|
||||||
sudo checkservices
|
if [ -x "$(command -v doas)" ]
|
||||||
|
then
|
||||||
|
doas checkservices
|
||||||
|
else
|
||||||
|
sudo checkservices
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "CHECKSERVICES SUCCEDEED"
|
echo "CHECKSERVICES SUCCEDEED"
|
||||||
|
|
Loading…
Reference in a new issue