[bash] fix doas completions

This commit is contained in:
odrling 2023-11-27 23:44:35 +01:00
parent b3c0c6c97d
commit 81e9648bac
No known key found for this signature in database
GPG key ID: E24CA7508C27AF5B
3 changed files with 24 additions and 4 deletions

4
.bash/completions Normal file
View file

@ -0,0 +1,4 @@
for i in ~/.bash/completions.d/*; do
. "$i"
done

19
.bash/completions.d/doas Normal file
View file

@ -0,0 +1,19 @@
# bash completion for doas(1) -*- shell-script -*-
_doas() {
local cur prev words cword split
_init_completion -s || return
for ((i = 1; i <= cword; i++)); do
if [[ ${words[i]} != -* ]]; then
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
local root_command=${words[i]}
_command_offset $i
return
fi
[[ ${words[i]} == -@(u|C) ]] && ((i++))
done
} && complete -F _doas doas
# ex: filetype=sh

View file

@ -26,10 +26,7 @@ export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
## Completions
[ -f /etc/bash_completion ] && . /etc/bash_completion
# doas/sudo command completion
complete -cf sudo
complete -cf doas
. ~/.bash/completions
# fzf
if command -v fzf 2>&1 > /dev/null; then