fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
6b5ad163d
master
1# Completion for doas https://github.com/multiplexd/doas 2# based on the sudo completions 3# 4 5function __fish_doas_print_remaining_args 6set -l tokens( commandline -xpc| string escape) ( commandline -ct) 7set -e tokens[ 1 ] 8# These are all the options mentioned in the man page for openbsd's "doas" (in that order). 9set -l opts a= C= L n s u= 10argparse -s$opts --$tokens 2> /dev/null 11# The remaining argv is the subcommand with all its options, which is what 12# we want. 13if test -n " $argv " 14and not string match -qr'^-' $argv [ 1 ] 15string join0 --$argv 16return 0 17else 18return 1 19end 20end 21 22function __fish_complete_doas_subcommand 23set -l args( __fish_doas_print_remaining_args | string split0) 24set -lx -a PATH /usr/local/sbin /sbin /usr/sbin 25__fish_complete_subcommand --commandline$args 26end 27 28complete -c doas -n"not __fish_doas_print_remaining_args" -s a -d"Choose auth method on systems using /etc/login.conf" 29complete -c doas -n"not __fish_doas_print_remaining_args" -s C -r -d"validate given config file and test it against given command" 30complete -c doas -n"not __fish_doas_print_remaining_args" -s L -d"Clear persisted authorizations, then exit" 31complete -c doas -n"not __fish_doas_print_remaining_args" -s n -d"Fail if doas would prompt for password" 32complete -c doas -n"not __fish_doas_print_remaining_args" -s s -d"Execute the shell from SHELL or /etc/passwd" 33complete -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." 34 35# Complete the command we are executing under doas 36complete -c doas -x -a"(__fish_complete_doas_subcommand)"