blob: b35c915206abc07674881bfbf2bfc87cae9653ee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
|