mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
bash-completion: cgls: suggests units
This commit is contained in:
parent
7c3940f6ce
commit
82ebb6ba1f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user