X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=shell-completion%2Fsystemd-zsh-completion.zsh;h=411646ea59f11d56e3f1522935b54ae74486683a;hb=99504dd4c13af7516a976fffc0f68e6f26d3faac;hp=a8f7081459236a28332eb3fcf9b9ee78eeeee48e;hpb=6af274272a917710f606acb3589f0430e9092631;p=elogind.git diff --git a/shell-completion/systemd-zsh-completion.zsh b/shell-completion/systemd-zsh-completion.zsh index a8f708145..411646ea5 100644 --- a/shell-completion/systemd-zsh-completion.zsh +++ b/shell-completion/systemd-zsh-completion.zsh @@ -12,6 +12,9 @@ _ctls() {-t,--type=}'[List only units of a particular type]:unit type:(automount device mount path service snapshot socket swap target timer)' \ \*{-p,--property=}'[Show only properties by specific name]:unit property' \ {-a,--all}'[Show all units/properties, including dead/empty ones]' \ + '--reverse[Show reverse dependencies]' \ + '--after[Show units ordered after]' \ + '--before[Show units ordered before]' \ '--failed[Show only failed units]' \ "--full[Don't ellipsize unit names on output]" \ '--fail[When queueing a new job, fail if conflicting jobs are pending]' \ @@ -291,11 +294,13 @@ _systemd_inhibit_command(){ _systemd_analyze_command(){ local -a _systemd_analyze_cmds + # Descriptions taken from systemd-analyze --help. _systemd_analyze_cmds=( - 'time:Print the time taken to start' - 'blame:prints a list of all running units, ordered by the time they took to initialize' - 'plot:prints an SVG graphic detailing which system services have been started at what time' - 'dot:Dump dependency graph for dot(1)' + 'time:Print time spent in the kernel before reaching userspace' + 'blame:Print list of running units ordered by time to init' + 'critical-chain:Print a tree of the time critical chain of units' + 'plot:Output SVG graphic showing service initialization' + 'dot:Dump dependency graph (in dot(1) format)' ) if (( CURRENT == 1 )); then @@ -348,6 +353,8 @@ _outputmodes() { "disable:Disable one or more unit files" "reenable:Reenable one or more unit files" "preset:Enable/disable one or more unit files based on preset configuration" + "help:Show documentation for specified units" + "list-dependencies:Show unit dependency tree" "mask:Mask one or more units" "unmask:Unmask one or more units" "link:Link one or more units files into the search path" @@ -404,7 +411,9 @@ _outputmodes() { __systemctl() { - systemctl --full --no-legend --no-pager "$@" + local -a _modes + _modes=("--user" "--system") + systemctl ${words:*_modes} --full --no-legend --no-pager "$@" } @@ -414,7 +423,7 @@ _systemctl_all_units() if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) && ! _retrieve_cache SYS_ALL_UNITS; then - _sys_all_units=( $(__systemctl list-units --all | { while read a b; do echo "$a"; done; }) ) + _sys_all_units=( $(__systemctl list-units --all | { while read a b; do echo " $a"; done; }) ) _store_cache SYS_ALL_UNITS _sys_all_units fi } @@ -427,7 +436,7 @@ _systemctl_really_all_units() if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) && ! _retrieve_cache SYS_REALLY_ALL_UNITS; then - all_unit_files=( $(__systemctl list-unit-files | { while read a b; do echo "$a"; done; }) ) + all_unit_files=( $(__systemctl list-unit-files | { while read a b; do echo " $a"; done; }) ) _systemctl_all_units really_all_units=($_sys_all_units $all_unit_files) _sys_really_all_units=(${(u)really_all_units}) @@ -447,20 +456,20 @@ _filter_units_by_property() { unit=${units[i]} prop=${(f)"$(_call_program units "$service show --no-pager --property="$property" ${unit} 2>/dev/null")"} if [[ "${prop}" = "$property=$value" ]]; then - echo "${unit}" + echo " ${unit}" fi done } -_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read a b; do echo "$a"; done; }) )} -_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all | { while read a b c d; do [[ $c == "inactive" ]] && echo "$a"; done; }) )} -_systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read a b; do echo "$a"; done; }) )} -_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "enabled" ]] && echo "$a"; done; }) )} -_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read a b; do [[ $b == "disabled" ]] && echo "$a"; done; }) )} -_systemctl_masked_units() {_sys_masked_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "masked" ]] && echo "$a"; done; }) )} +_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read a b; do echo " $a"; done; }) )} +_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all | { while read a b c d; do [[ $c == "inactive" || $c == "failed" ]] && echo " $a"; done; }) )} +_systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read a b; do echo " $a"; done; }) )} +_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "enabled" ]] && echo " $a"; done; }) )} +_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read a b; do [[ $b == "disabled" ]] && echo " $a"; done; }) )} +_systemctl_masked_units() {_sys_masked_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "masked" ]] && echo " $a"; done; }) )} # Completion functions for ALL_UNITS -for fun in is-active is-failed is-enabled status show mask preset ; do +for fun in is-active is-failed is-enabled status show mask preset help list-dependencies ; do (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() { _systemctl_really_all_units @@ -473,7 +482,8 @@ for fun in disable reenable ; do (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() { _systemctl_enabled_units - compadd "$@" -a - _sys_enabled_units + _systemctl_disabled_units + compadd "$@" -a - _sys_enabled_units _sys_disabled_units } done @@ -533,7 +543,7 @@ for fun in restart reload-or-restart ; do _systemctl_all_units compadd "$@" - $( _filter_units_by_property CanStart yes \ ${_sys_all_units[*]} | while read line; do \ - [[ "$line" =~ \.(device|snapshot|socket|timer)$ ]] || echo "$line"; \ + [[ "$line" =~ \.device$ ]] || echo " $line"; \ done ) } done @@ -556,7 +566,7 @@ done (( $+functions[_systemctl_delete] )) || _systemctl_delete() { compadd "$@" - $(__systemctl list-units --type snapshot --all \ - | cut -d' ' -f1 2>/dev/null ) || _message "no snampshot found" + | cut -d' ' -f1 2>/dev/null ) || _message "no snapshot found" } # Completion functions for ENVS @@ -570,7 +580,7 @@ for fun in set-environment unset-environment ; do fi compadd "$@" ${suf} - $(systemctl show-environment \ - | while read line; do echo "${line%%\=}";done ) + | while read line; do echo " ${line%%\=}";done ) } done @@ -636,9 +646,9 @@ _journal_fields() { } -_loginctl_all_sessions(){_sys_all_sessions=($(loginctl list-sessions | { while read a b; do echo "$a"; done; }) )} -_loginctl_all_users() {_sys_all_users=( $(loginctl list-users | { while read a b; do echo "$a"; done; }) )} -_loginctl_all_seats() {_sys_all_seats=( $(loginctl list-seats | { while read a b; do echo "$a"; done; }) )} +_loginctl_all_sessions(){_sys_all_sessions=($(loginctl list-sessions | { while read a b; do echo " $a"; done; }) )} +_loginctl_all_users() {_sys_all_users=( $(loginctl list-users | { while read a b; do echo " $a"; done; }) )} +_loginctl_all_seats() {_sys_all_seats=( $(loginctl list-seats | { while read a b; do echo " $a"; done; }) )} # Completion functions for SESSIONS for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do @@ -886,12 +896,13 @@ _systemd-coredumpctl_command(){ _describe -t commands 'systemd-coredumpctl command' _systemd_coredumpctl_cmds else local curcontext="$curcontext" - local -a dumps + local -a _dumps cmd="${${_systemd_coredumpctl_cmds[(r)$words[1]:*]%%:*}}" if (( $#cmd )); then - dumps=( "${(f)$(_call_program dumps "systemd-coredumpctl list 2>/dev/null")}" ) - if [[ -n "$dumps" ]]; then - compadd "${dumps[@]}" + # user can set zstyle ':completion:*:*:systemd-coredumpctl:*' sort no for coredumps to be ordered by date, otherwise they get ordered by pid + _dumps=( "${(foa)$(systemd-coredumpctl list | awk 'BEGIN{OFS=":"} /^\s/ {sub(/[[ \t]+/, ""); print $5,$0}' 2>/dev/null)}" ) + if [[ -n "$_dumps" ]]; then + _describe -t pids 'coredumps' _dumps else _message "no coredumps" fi @@ -961,7 +972,7 @@ _udevadm_monitor(){ '--kernel[Print the kernel uevents.]' \ '--udev[Print the udev event after the rule processing.]' \ '--property[Also print the properties of the event.]' \ - '--subsystem-match=[Filter events by subsystem[/devtype].]' \ + '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \ '--tag-match=[Filter events by property.]' \ '--help[Print help text.]' }