diff options
author | Luca Matei Pintilie <lucafulger@gmail.com> | 2022-11-26 13:26:05 +0000 |
---|---|---|
committer | Luca Matei Pintilie <lucafulger@gmail.com> | 2022-11-26 13:26:05 +0000 |
commit | 84153502db8b3b0c0d5e7555802d5d53d3bcc3d7 (patch) | |
tree | 2ff63c89ae00207e26e229938cf008bc686db7fd /.local/share/bash-completion/doas | |
parent | 8497608cef900bd8820195364acd9307dd8b3d4c (diff) | |
download | dotfiles-84153502db8b3b0c0d5e7555802d5d53d3bcc3d7.tar dotfiles-84153502db8b3b0c0d5e7555802d5d53d3bcc3d7.tar.gz dotfiles-84153502db8b3b0c0d5e7555802d5d53d3bcc3d7.tar.bz2 dotfiles-84153502db8b3b0c0d5e7555802d5d53d3bcc3d7.tar.lz dotfiles-84153502db8b3b0c0d5e7555802d5d53d3bcc3d7.tar.xz dotfiles-84153502db8b3b0c0d5e7555802d5d53d3bcc3d7.tar.zst dotfiles-84153502db8b3b0c0d5e7555802d5d53d3bcc3d7.zip |
Add bash completion
Diffstat (limited to '.local/share/bash-completion/doas')
-rwxr-xr-x | .local/share/bash-completion/doas | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/.local/share/bash-completion/doas b/.local/share/bash-completion/doas new file mode 100755 index 0000000..b35c915 --- /dev/null +++ b/.local/share/bash-completion/doas @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# bash completion for sudo(8) +# Adapted for doas +# https://github.com/scop/bash-completion/blob/730368b35aeb7f9b7eec62ff0e19b1bd8b385961/completions/sudo +_sudo() +{ + local cur prev words cword split + _init_completion -s || return + + local i mode=normal + + [[ $mode == normal ]] && + 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]} == -@(!(-*)[uC]) ]] && + ((i++)) + done + + case "$prev" in + -u) + COMPREPLY=($(compgen -u -- "$cur")) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=($( + compgen -W '$(_parse_usage "$1")' -- "$cur" + )) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + return + fi +} + +complete -F _sudo doas + |