ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
65878a
From d437087966e4a5f7ad0b37b4254988de41e16228 Mon Sep 17 00:00:00 2001
65878a
From: Ronny Chevalier <chevalier.ronny@gmail.com>
65878a
Date: Wed, 30 Oct 2013 21:57:44 +0100
65878a
Subject: [PATCH] zsh-completion: add systemd-run
65878a
65878a
---
65878a
 Makefile.am                       |  1 +
65878a
 shell-completion/zsh/_systemd-run | 31 +++++++++++++++++++++++++++++++
65878a
 2 files changed, 32 insertions(+)
65878a
 create mode 100644 shell-completion/zsh/_systemd-run
65878a
65878a
diff --git a/Makefile.am b/Makefile.am
65878a
index 8d9c587..0c11477 100644
65878a
--- a/Makefile.am
65878a
+++ b/Makefile.am
65878a
@@ -352,6 +352,7 @@ dist_zshcompletion_DATA = \
65878a
 	shell-completion/zsh/_kernel-install \
65878a
 	shell-completion/zsh/_systemd-nspawn \
65878a
 	shell-completion/zsh/_systemd-analyze \
65878a
+	shell-completion/zsh/_systemd-run \
65878a
 	shell-completion/zsh/_sd_hosts_or_user_at_host \
65878a
 	shell-completion/zsh/_systemd-delta \
65878a
 	shell-completion/zsh/_systemd
65878a
diff --git a/shell-completion/zsh/_systemd-run b/shell-completion/zsh/_systemd-run
65878a
new file mode 100644
65878a
index 0000000..0c81c54
65878a
--- /dev/null
65878a
+++ b/shell-completion/zsh/_systemd-run
65878a
@@ -0,0 +1,31 @@
65878a
+#compdef systemd-run
65878a
+
65878a
+__systemctl() {
65878a
+        local -a _modes
65878a
+        _modes=("--user" "--system")
65878a
+        systemctl ${words:*_modes} --full --no-legend --no-pager "$@" 2>/dev/null
65878a
+}
65878a
+
65878a
+__get_slices () {
65878a
+        __systemctl list-units --all -t slice \
65878a
+        | { while read -r a b; do echo $a; done; };
65878a
+}
65878a
+
65878a
+__slices () {
65878a
+        local -a _slices
65878a
+        _slices=(${(fo)"$(__get_slices)"})
65878a
+        typeset -U _slices
65878a
+        _describe 'slices' _slices
65878a
+}
65878a
+
65878a
+_arguments \
65878a
+        {-h,--help}'[Show help message]' \
65878a
+        '--version[Show package version]' \
65878a
+        '--user[Run as user unit]' \
65878a
+        '--scope[Run this as scope rather than service]' \
65878a
+        '--unit=[Run under the specified unit name]:unit name' \
65878a
+        '--description=[Description for unit]:description' \
65878a
+        '--slice=[Run in the specified slice]:slices:__slices' \
65878a
+        {-r,--remain-after-exit}'[Leave service around until explicitly stopped]' \
65878a
+        '--send-sighup[Send SIGHUP when terminating]' \
65878a
+        '*::command:_command'