summaryrefslogtreecommitdiff
path: root/shell-completion/zsh/_sd_machines
diff options
context:
space:
mode:
authorWilliam Giokas <1007380@gmail.com>2013-11-07 16:00:51 -0600
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-11-09 19:02:53 -0500
commitc0fd7cbd7a3a0aab503393e648b33b6ad49ec485 (patch)
tree56087053bdf2c1ebf0336cf8c83e542cc3be887b /shell-completion/zsh/_sd_machines
parenta02c5fe7cbad3ca0536286ceab0bde5fb1c0ba13 (diff)
zsh-completion: Move machine listing to autoload
Instead of having two different listings of machines, use an autoloaded function that can be used by other shell completions in the future. It will also allow editing a single file to change the way machinectl and systemd-run completion for machines.
Diffstat (limited to 'shell-completion/zsh/_sd_machines')
-rw-r--r--shell-completion/zsh/_sd_machines13
1 files changed, 13 insertions, 0 deletions
diff --git a/shell-completion/zsh/_sd_machines b/shell-completion/zsh/_sd_machines
new file mode 100644
index 0000000000..1d64d13b1a
--- /dev/null
+++ b/shell-completion/zsh/_sd_machines
@@ -0,0 +1,13 @@
+#autoload
+__get_machines () {
+ machinectl --full --no-pager list | {while read -r a b; do echo $a; done;};
+}
+
+local -a _machines
+_machines=("${(fo)$(__get_machines)}")
+typeset -U _machines
+if [[ -n "$_machines" ]]; then
+ _describe 'machines' _machines
+else
+ _message 'no machines'
+fi