1 #compdef systemd-analyze
3 _systemd_analyze_set-log-level() {
5 _levels=(debug info notice warning err crit alert emerg)
6 _describe -t level 'logging level' _levels || compadd "$@"
9 _systemd_analyze_command(){
10 local -a _systemd_analyze_cmds
11 # Descriptions taken from systemd-analyze --help.
12 _systemd_analyze_cmds=(
13 'time:Print time spent in the kernel before reaching userspace'
14 'blame:Print list of running units ordered by time to init'
15 'critical-chain:Print a tree of the time critical chain of units'
16 'plot:Output SVG graphic showing service initialization'
17 'dot:Dump dependency graph (in dot(1) format)'
18 'set-log-level:Set systemd log threshold'
21 if (( CURRENT == 1 )); then
22 _describe "options" _systemd_analyze_cmds
24 local curcontext="$curcontext"
25 cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}"
27 if (( $+functions[_systemd_analyze_$cmd] )) && (( CURRENT == 2 )); then
30 _message "no more options"
33 _message "unknown systemd-analyze command: $words[1]"
39 {-h,--help}'[Show help text.]' \
40 '--user[Shows performance data of user sessions instead of the system manager.]' \
41 '--order[When generating graph for dot, show only order]' \
42 '--require[When generating graph for dot, show only requirement]' \
43 '*::systemd-analyze commands:_systemd_analyze_command'