mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fix completions for service
I'm not sure what was up with the old completions, `$__fish_service_commands` is not set anywhere and completions for the command (not the service) were not being generated on my machine.
This commit is contained in:
parent
fd14e459cf
commit
c8c3265cb8
2 changed files with 16 additions and 2 deletions
|
@ -80,6 +80,7 @@ This section is for changes merged to the `major` branch that are not also merge
|
|||
- `git` (#4395, #4396, #4592)
|
||||
- `npm`<sup>†</sup>
|
||||
- `python`/`python2`/`python3`
|
||||
- `service`
|
||||
- `ssh` (#4344)
|
||||
- `sudo` (see above)
|
||||
- `yarn`<sup>∗</sup><sup>†</sup>
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
set -l service_commands
|
||||
|
||||
# as found in __fish_print_service_names.fish
|
||||
if test -d /run/systemd/system # Systemd systems
|
||||
set service_commands start stop restart status enable disable
|
||||
else if type -f rc-service 2>/dev/null # OpenRC (Gentoo)
|
||||
set service_commands start stop restart
|
||||
else if test -d /etc/init.d # SysV on Debian and other linuxen
|
||||
set service_commands start stop "--full-restart"
|
||||
else # FreeBSD
|
||||
set service_commands start stop start_once stop_once
|
||||
end
|
||||
|
||||
# Fist argument is the names of the service, i.e. a file in /etc/init.d
|
||||
complete -c service -n "test (count (commandline -poc)) = 1" -xa "(__fish_print_service_names)" -d "Service name"
|
||||
complete -c service -n "__fish_is_first_token" -xa "(__fish_print_service_names)" -d "Service name"
|
||||
|
||||
#The second argument is what action to take with the service
|
||||
complete -c service -n "test (count (commandline -poc)) -gt 1" -xa '$__fish_service_commands'
|
||||
complete -c service -n "not __fish_is_first_token" -xa "$service_commands"
|
||||
|
||||
|
|
Loading…
Reference in a new issue