|
Zbigniew Jędrzejewski-Szmek |
96237b |
From 7f197e46c944bdb43fa1cedbd97708ac2ea72558 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: Tue, 4 Mar 2014 23:16:30 +0100
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
Subject: [PATCH] add bash completion for systemd-cat
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
(cherry picked from commit 207017017db91232189226bfcf29e61926310a9b)
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
---
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
Makefile.am | 1 +
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-cat | 57 +++++++++++++++++++++++++++++++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
2 files changed, 58 insertions(+)
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
create mode 100644 shell-completion/bash/systemd-cat
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
diff --git a/Makefile.am b/Makefile.am
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
index 834ed6f..7187b8d 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-cat \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-cgls \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-cgtop \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
shell-completion/bash/systemd-delta \
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
diff --git a/shell-completion/bash/systemd-cat b/shell-completion/bash/systemd-cat
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
new file mode 100644
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
index 0000000..8d84042
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
--- /dev/null
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+++ b/shell-completion/bash/systemd-cat
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
@@ -0,0 +1,57 @@
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+# systemd-cat(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 |
+_systemd_cat() {
|
|
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'
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ [ARG]='-t --identifier -p --priority --level-prefix'
|
|
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 |
+ --identifier|-t)
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ comps=''
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ ;;
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ --priority|-p)
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ comps='emerg alert crit err warning notice info debug'
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ ;;
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ --level-prefix)
|
|
Zbigniew Jędrzejewski-Szmek |
96237b |
+ comps='yes no'
|
|
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_cat systemd-cat
|