|
Zbigniew Jędrzejewski-Szmek |
96237b |
From 8523c2a84f3d8a8b163a17aad5c55cb0234ebff2 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
Date: Sat, 1 Mar 2014 23:08:38 +0100
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
Subject: [PATCH] add bash completion for systemd-cgls
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
(cherry picked from commit abdab4f602745952030a37b1521cd0374d51d3ea)
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
---
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
Makefile.am | 1 +
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-cgls | 56 ++++++++++++++++++++++++++++++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
2 files changed, 57 insertions(+)
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
create mode 100644 shell-completion/bash/systemd-cgls
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
diff --git a/Makefile.am b/Makefile.am
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
index 8e6c392..0b83823 100644
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
--- a/Makefile.am
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+++ b/Makefile.am
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
@@ -352,6 +352,7 @@ dist_bashcompletion_DATA = \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/journalctl \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemctl \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-analyze \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ shell-completion/bash/systemd-cgls \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-delta \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-nspawn \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-run \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
diff --git a/shell-completion/bash/systemd-cgls b/shell-completion/bash/systemd-cgls
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
new file mode 100644
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
index 0000000..0570438
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
--- /dev/null
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+++ b/shell-completion/bash/systemd-cgls
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
@@ -0,0 +1,56 @@
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# systemd-cgls(1) completion -*- shell-script -*-
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+#
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# This file is part of systemd.
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+#
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# Copyright 2014 Thomas H.P. Andersen
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+#
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# systemd is free software; you can redistribute it and/or modify it
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# under the terms of the GNU Lesser General Public License as published by
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# the Free Software Foundation; either version 2.1 of the License, or
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# (at your option) any later version.
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+#
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# systemd is distributed in the hope that it will be useful, but
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# General Public License for more details.
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+#
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# You should have received a copy of the GNU Lesser General Public License
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+__contains_word() {
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ local w word=$1; shift
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ for w in "$@"; do
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ [[ $w = "$word" ]] && return
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ done
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+__get_machines() {
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ local a b
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+_systemd_cgls() {
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ local i verb comps
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ local -A OPTS=(
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ [STANDALONE]='-h --help --version --all -l --full -k --no-pager'
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ [ARG]='-M --machine'
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ )
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ _init_completion || return
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ if __contains_word "$prev" ${OPTS[ARG]}; then
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ case $prev in
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ --machine|-M)
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ comps=$( __get_machines )
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ ;;
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ esac
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ return 0
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ fi
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+complete -F _systemd_cgls systemd-cgls
|