daandemeyer / rpms / systemd

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