96237b5
From 6b4293393eb0a15e4f73ba9f08554178ccc4c222 Mon Sep 17 00:00:00 2001
96237b5
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
96237b5
Date: Sun, 2 Mar 2014 22:58:18 +0100
96237b5
Subject: [PATCH] add bash completion for systemd-cgtop
96237b5
96237b5
(cherry picked from commit d9256bac4da4241cb5d97960c899390839f2c6e5)
96237b5
---
96237b5
 Makefile.am                         |  1 +
96237b5
 shell-completion/bash/systemd-cgtop | 40 +++++++++++++++++++++++++++++++++++++
96237b5
 2 files changed, 41 insertions(+)
96237b5
 create mode 100644 shell-completion/bash/systemd-cgtop
96237b5
96237b5
diff --git a/Makefile.am b/Makefile.am
96237b5
index 0b83823..9cabd1d 100644
96237b5
--- a/Makefile.am
96237b5
+++ b/Makefile.am
96237b5
@@ -353,6 +353,7 @@ dist_bashcompletion_DATA = \
96237b5
 	shell-completion/bash/systemctl \
96237b5
 	shell-completion/bash/systemd-analyze \
96237b5
 	shell-completion/bash/systemd-cgls \
96237b5
+	shell-completion/bash/systemd-cgtop \
96237b5
 	shell-completion/bash/systemd-delta \
96237b5
 	shell-completion/bash/systemd-nspawn \
96237b5
 	shell-completion/bash/systemd-run \
96237b5
diff --git a/shell-completion/bash/systemd-cgtop b/shell-completion/bash/systemd-cgtop
96237b5
new file mode 100644
96237b5
index 0000000..d7ea42d
96237b5
--- /dev/null
96237b5
+++ b/shell-completion/bash/systemd-cgtop
96237b5
@@ -0,0 +1,40 @@
96237b5
+# systemd-cgtop(1) completion                  -*- shell-script -*-
96237b5
+#
96237b5
+# This file is part of systemd.
96237b5
+#
96237b5
+# Copyright 2014 Thomas H.P. Andersen
96237b5
+#
96237b5
+# systemd is free software; you can redistribute it and/or modify it
96237b5
+# under the terms of the GNU Lesser General Public License as published by
96237b5
+# the Free Software Foundation; either version 2.1 of the License, or
96237b5
+# (at your option) any later version.
96237b5
+#
96237b5
+# systemd is distributed in the hope that it will be useful, but
96237b5
+# WITHOUT ANY WARRANTY; without even the implied warranty of
96237b5
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
96237b5
+# General Public License for more details.
96237b5
+#
96237b5
+# You should have received a copy of the GNU Lesser General Public License
96237b5
+# along with systemd; If not, see <http://www.gnu.org/licenses/>.
96237b5
+
96237b5
+__contains_word() {
96237b5
+        local w word=$1; shift
96237b5
+        for w in "$@"; do
96237b5
+                [[ $w = "$word" ]] && return
96237b5
+        done
96237b5
+}
96237b5
+
96237b5
+_systemd_cgtop() {
96237b5
+        local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
96237b5
+        local comps
96237b5
+
96237b5
+        local -A OPTS=(
96237b5
+               [STANDALONE]='-h --help --version -p -t -c -m -i -b --batch -n --iterations -d --delay'
96237b5
+        )
96237b5
+
96237b5
+        _init_completion || return
96237b5
+
96237b5
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
96237b5
+}
96237b5
+
96237b5
+complete -F _systemd_cgtop systemd-cgtop