diff options
author | 2016-02-07 14:52:08 +0100 | |
---|---|---|
committer | 2016-02-07 14:53:12 +0100 | |
commit | 57fcbecb41ad54cb9a3ef968787dd990de030f4c (patch) | |
tree | 42e0e9152a5a5417b7171ebf8d0238f66846a738 /share/functions | |
parent | c4d0612e5c0fbc0dd118ade84c9be055e0f2ea89 (diff) |
Improve __fish_print_service_names
- Reuse systemd completion functions
- Remove a fork
- Fix #2715 - FreeBSD
- Comments
Diffstat (limited to 'share/functions')
-rw-r--r-- | share/functions/__fish_print_service_names.fish | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/share/functions/__fish_print_service_names.fish b/share/functions/__fish_print_service_names.fish index 8b2926ed..e216b750 100644 --- a/share/functions/__fish_print_service_names.fish +++ b/share/functions/__fish_print_service_names.fish @@ -1,9 +1,13 @@ function __fish_print_service_names -d 'All services known to the system' - if test -d /run/systemd/system - command systemctl list-units -t service | cut -d ' ' -f 1 | grep '\.service$' | sed -e 's/\.service$//' - else if type -f rc-service 2> /dev/null + if test -d /run/systemd/system # Systemd systems + # For the `service` command, this needs to be without the type suffix + # on Debian at least + __fish_systemctl_services | string replace -r '.service$' '' + else if type -f rc-service ^/dev/null # OpenRC (Gentoo) command rc-service -l - else - command ls /etc/init.d + else if test -d /etc/init.d # SysV on Debian and other linuxen + string replace '/etc/init.d/' '' -- /etc/init.d/* + else # Freebsd + command service -l end end |