cgtop: add -M/--machine

This commit is contained in:
Evgeny Vereshchagin
2015-09-21 12:04:45 +00:00
parent 8c710f3ce6
commit 96a6426f30
3 changed files with 80 additions and 3 deletions
+16 -1
View File
@@ -24,17 +24,32 @@ __contains_word() {
done
}
__get_machines() {
local a b
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
}
_systemd_cgtop() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local comps
local -A OPTS=(
[STANDALONE]='-h --help --version -p -t -c -m -i -b --batch -n --iterations -d --delay'
[ARG]='--cpu --depth'
[ARG]='--cpu --depth -M --machine'
)
_init_completion || return
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--machine|-M)
comps=$( __get_machines )
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
}