From 00e0ed64bc2e4b918357b10fbd176797eeb07402 Mon Sep 17 00:00:00 2001 From: David Adam Date: Mon, 10 Nov 2014 12:50:17 +0800 Subject: __fish_systemctl_*: use systemctl to generate the list of units Closes #1804. Note that if systemd is not running, the completion will fail. --- share/functions/__fish_systemctl_mounts.fish | 5 +++-- share/functions/__fish_systemctl_service_paths.fish | 5 +++-- share/functions/__fish_systemctl_services.fish | 5 +++-- share/functions/__fish_systemctl_sockets.fish | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'share') diff --git a/share/functions/__fish_systemctl_mounts.fish b/share/functions/__fish_systemctl_mounts.fish index 706e6ee8..5f23bba1 100644 --- a/share/functions/__fish_systemctl_mounts.fish +++ b/share/functions/__fish_systemctl_mounts.fish @@ -1,4 +1,5 @@ function __fish_systemctl_mounts - command find /etc/systemd/system -type f -name '*.mount' -printf '%f\n' - command find /usr/lib/systemd/system -type f -name '*.mount' -printf '%f\n' + if type -q systemctl + systemctl list-unit-files --no-legend --type=mount ^/dev/null | cut -f 1 -d ' ' + end end diff --git a/share/functions/__fish_systemctl_service_paths.fish b/share/functions/__fish_systemctl_service_paths.fish index 6f8435cf..2f79ec10 100644 --- a/share/functions/__fish_systemctl_service_paths.fish +++ b/share/functions/__fish_systemctl_service_paths.fish @@ -1,4 +1,5 @@ function __fish_systemctl_service_paths - command find /etc/systemd/system -type f -name '*.path' -printf '%f\n' - command find /usr/lib/systemd/system -type f -name '*.path' -printf '%f\n' + if type -q systemctl + systemctl list-unit-files --no-legend --type=path ^/dev/null | cut -f 1 -d ' ' + end end diff --git a/share/functions/__fish_systemctl_services.fish b/share/functions/__fish_systemctl_services.fish index a9fd38ba..f48cb324 100644 --- a/share/functions/__fish_systemctl_services.fish +++ b/share/functions/__fish_systemctl_services.fish @@ -1,4 +1,5 @@ function __fish_systemctl_services - command find /etc/systemd/system -type f -name '*.service' -printf '%f\n' - command find /usr/lib/systemd/system -type f -name '*.service' -printf '%f\n' + if type -q systemctl + systemctl list-unit-files --no-legend --type=service ^/dev/null | cut -f 1 -d ' ' + end end diff --git a/share/functions/__fish_systemctl_sockets.fish b/share/functions/__fish_systemctl_sockets.fish index 0fe5b6e8..ecb61ea2 100644 --- a/share/functions/__fish_systemctl_sockets.fish +++ b/share/functions/__fish_systemctl_sockets.fish @@ -1,4 +1,5 @@ function __fish_systemctl_sockets - command find /etc/systemd/system -type f -name '*.socket' -printf '%f\n' - command find /usr/lib/systemd/system -type f -name '*.socket' -printf '%f\n' + if type -q systemctl + systemctl list-unit-files --no-legend --type=socket ^/dev/null | cut -f 1 -d ' ' + end end -- cgit v1.2.3