summaryrefslogtreecommitdiff
path: root/shell-completion
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-01-10 21:47:08 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-01-10 23:19:00 +0900
commit82ebb6ba1f36a9f983841b69a795ff237790097c (patch)
tree204795b0a550abadc423ef0f5cba537fd3b26a55 /shell-completion
parent7c3940f6ce08b61d944e0802709f3767d833a234 (diff)
bash-completion: cgls: suggests units
Diffstat (limited to 'shell-completion')
-rw-r--r--shell-completion/bash/systemd-cgls16
1 files changed, 15 insertions, 1 deletions
diff --git a/shell-completion/bash/systemd-cgls b/shell-completion/bash/systemd-cgls
index 0f579a6e67..34c7b9e67f 100644
--- a/shell-completion/bash/systemd-cgls
+++ b/shell-completion/bash/systemd-cgls
@@ -30,13 +30,21 @@ __get_machines() {
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
}
+__get_units_have_cgroup() {
+ systemctl $1 list-units | {
+ while read -r a b c d; do
+ [[ $c == "active" && ${a##*.} =~ (service|socket|mount|swap|slice|scope) ]] && echo " $a"
+ done
+ };
+}
+
_systemd_cgls() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local i verb comps
local -A OPTS=(
[STANDALONE]='-h --help --version --all -l --full -k --no-pager'
- [ARG]='-M --machine'
+ [ARG]='-M --machine -u --unit --user-unit'
)
_init_completion || return
@@ -46,6 +54,12 @@ _systemd_cgls() {
--machine|-M)
comps=$( __get_machines )
;;
+ --unit|-u)
+ comps=$( __get_units_have_cgroup --system )
+ ;;
+ --user-unit)
+ comps=$( __get_units_have_cgroup --user )
+ ;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0