2018-09-25 18:31:46 +08:00
|
|
|
# Completion for doas https://github.com/multiplexd/doas
|
|
|
|
# based on the sudo completions
|
|
|
|
#
|
|
|
|
|
|
|
|
function __fish_doas_print_remaining_args
|
2024-01-22 14:42:45 +08:00
|
|
|
set -l tokens (commandline -xpc) (commandline -ct)
|
2018-09-25 18:31:46 +08:00
|
|
|
set -e tokens[1]
|
|
|
|
# These are all the options mentioned in the man page for openbsd's "doas" (in that order).
|
|
|
|
set -l opts a= C= L n s u=
|
|
|
|
argparse -s $opts -- $tokens 2>/dev/null
|
|
|
|
# The remaining argv is the subcommand with all its options, which is what
|
|
|
|
# we want.
|
|
|
|
if test -n "$argv"
|
|
|
|
and not string match -qr '^-' $argv[1]
|
2019-11-16 14:50:54 +08:00
|
|
|
string join0 -- $argv
|
2018-09-25 18:31:46 +08:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_complete_doas_subcommand
|
2019-11-16 14:50:54 +08:00
|
|
|
set -l args (__fish_doas_print_remaining_args | string split0)
|
2019-11-02 00:20:09 +08:00
|
|
|
set -lx -a PATH /usr/local/sbin /sbin /usr/sbin
|
2019-11-05 17:56:03 +08:00
|
|
|
__fish_complete_subcommand --commandline $args
|
2018-09-25 18:31:46 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
complete -c doas -n "not __fish_doas_print_remaining_args" -s a -d "Choose auth method on systems using /etc/login.conf"
|
|
|
|
complete -c doas -n "not __fish_doas_print_remaining_args" -s C -r -d "validate given config file and test it against given command"
|
|
|
|
complete -c doas -n "not __fish_doas_print_remaining_args" -s L -d "Clear persisted authorizations, then exit"
|
|
|
|
complete -c doas -n "not __fish_doas_print_remaining_args" -s n -d "Fail if doas would prompt for password"
|
|
|
|
complete -c doas -n "not __fish_doas_print_remaining_args" -s s -d "Execute the shell from SHELL or /etc/passwd"
|
|
|
|
complete -c doas -n "not __fish_doas_print_remaining_args" -s u -a "(__fish_complete_users)" -x -d "Execute the command as user. The default is root."
|
|
|
|
|
|
|
|
# Complete the command we are executing under doas
|
|
|
|
complete -c doas -x -a "(__fish_complete_doas_subcommand)"
|