mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Add completions for openbsd's doas (#5196)
* Add completions for openbsd's doas * Update CHANGELOG.md * Implement requested changes
This commit is contained in:
parent
a483643626
commit
794b448c00
|
@ -21,6 +21,7 @@ fish 3.0 is a major release which brings with it both improvements in functional
|
|||
- Background jobs not first `disown`'d will be reaped upon `exec`, bringing the behavior in line with that of `exit`.
|
||||
|
||||
## Notable fixes and improvements
|
||||
- Add completions for openbsd's doas.
|
||||
- A new feature flags mechanism is added for staging deprecations and breaking changes. Feature flags may be specified at launch with `fish --features ...` or by setting the universal `fish_features` variable. (#4940)
|
||||
- `exec` now triggers the same safety features as `exit` and prompts for confirmation if background jobs are running.
|
||||
- `wait` builtin is added for waiting on processes (#4498).
|
||||
|
|
37
share/completions/doas.fish
Normal file
37
share/completions/doas.fish
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/fish
|
||||
#
|
||||
# Completion for doas https://github.com/multiplexd/doas
|
||||
# based on the sudo completions
|
||||
#
|
||||
|
||||
function __fish_doas_print_remaining_args
|
||||
set -l tokens (commandline -opc) (commandline -ct)
|
||||
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]
|
||||
echo $argv
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_complete_doas_subcommand
|
||||
set -l args (__fish_doas_print_remaining_args)
|
||||
complete -C"$args"
|
||||
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)"
|
Loading…
Reference in New Issue
Block a user