X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=shell-completion%2Fsystemd-zsh-completion.zsh;h=1ab1311ec149b0ffc4333ca608f712c95acd27f9;hp=5f75bc31b12c7e7634786d706c605fbc78916c90;hb=5c7951141fa9f33e1b97de97586cc16bce2776e0;hpb=12514db7d099bd66ad71cd4684bbf97a200b08fa diff --git a/shell-completion/systemd-zsh-completion.zsh b/shell-completion/systemd-zsh-completion.zsh index 5f75bc31b..1ab1311ec 100644 --- a/shell-completion/systemd-zsh-completion.zsh +++ b/shell-completion/systemd-zsh-completion.zsh @@ -1,4 +1,4 @@ -#compdef systemctl loginctl journalctl hostnamectl localectl timedatectl systemd-coredumpctl udevadm systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-inhibit systemd-machine-id-setup systemd-notify systemd-nspawn systemd-tmpfiles systemd-tty-ask-password-agent +#compdef systemctl loginctl journalctl hostnamectl localectl timedatectl systemd-coredumpctl udevadm systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-inhibit systemd-machine-id-setup systemd-notify systemd-nspawn systemd-tmpfiles systemd-tty-ask-password-agent machinectl _ctls() { @@ -12,8 +12,11 @@ _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]" \ + {-l,--full}"[Don't ellipsize unit names on output]" \ '--fail[When queueing a new job, fail if conflicting jobs are pending]' \ '--ignore-dependencies[When queueing a new job, ignore all its dependencies]' \ '--kill-who=[Who to send signal to]:killwho:(main control all)' \ @@ -27,8 +30,6 @@ _ctls() '--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \ '--no-pager[Do not pipe output into a pager]' \ '--no-ask-password[Do not ask for system passwords]' \ - '--order[When generating graph for dot, show only order]' \ - '--require[When generating graph for dot, show only requirement]' \ '--system[Connect to system manager]' \ '--user[Connect to user service manager]' \ '--global[Enable/disable unit files globally]' \ @@ -70,13 +71,17 @@ _ctls() '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \ '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \ {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \ + '--system[Show system and kernel messages]' \ + '--user[Show messages from user services]' \ {-b,--this-boot}'[Show data only from current boot]' \ {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \ + '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \ {-p,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \ {-f,--follow}'[Follow journal]' \ {-n,--lines=}'[Number of journal entries to show]:integer' \ '--no-tail[Show all lines, even in follow mode]' \ {-o,--output=}'[Change journal output mode]:output modes:_outputmodes' \ + {-l,--full}'[Show long fields in full]' \ {-a,--all}'[Show all fields, including long and unprintable]' \ {-q,--quiet}"[Don't show privilege warning]" \ '--no-pager[Do not pipe output into a pager]' \ @@ -94,6 +99,7 @@ _ctls() '--verify[Verify journal file consistency]' \ '--list-catalog[List messages in catalog]' \ '--update-catalog[Update binary catalog database]' \ + '*::default: _journal_none' ;; localectl) _arguments \ @@ -135,6 +141,8 @@ _ctls() _arguments \ {-h,--help}'[Show help text.]' \ '--user[Shows performance data of user sessions instead of the system manager.]' \ + '--order[When generating graph for dot, show only order]' \ + '--require[When generating graph for dot, show only requirement]' \ '*::systemd-analyze commands:_systemd_analyze_command' ;; systemd-ask-password) @@ -241,6 +249,7 @@ _ctls() '--clean[Clean up all files and directories with an age parameter configured.]' \ '--remove[All files and directories marked with r, R in the configuration files are removed.]' \ '--prefix=[Only apply rules that apply to paths with the specified prefix.]' \ + '--exclude-prefix=[Ignore rules that apply to paths with the specified prefix.]' \ '--help[Prints a short help text and exits.]' \ '*::files:_files' ;; @@ -255,6 +264,21 @@ _ctls() '--plymouth[Ask question with plymouth(8).]' \ '--console[Ask question on /dev/console.]' ;; + machinectl) + _arguments \ + {-h,--help}'[Prints a short help text and exits.]' \ + '--version[Prints a short version string and exits.]' \ + {-p,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \ + {-a,--all}'[Show all proerties]' \ + (-l,--full)'[Do not ellipsize cgroup members]' \ + '--no-pager[Do not pipe output into a pager]' \ + '--no-ask-password[Do not ask for system passwords]' \ + '--kill-who=[Who to send signal to]:killwho:(leader all)' \ + {-s,--signal=}'[Which signal to send]:signal:_signals' \ + {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \ + {-P,--privileged}'[Acquire privileges before execution]' \ + '*::machinectl command:_machinectl_command' + ;; *) _message 'eh?' ;; esac } @@ -270,7 +294,7 @@ _systemd-nspawn(){ } _systemd_inhibit_command(){ - if (( CURRENT == 1 )); then + if (( CURRENT == 1 )); then compset -q _normal else @@ -288,10 +312,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' + '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 @@ -313,7 +340,7 @@ _outputmodes() { _output_opts=(short short-monotonic verbose export json json-pretty json-see cat) _describe -t output 'output mode' _output_opts || compadd "$@" } - + (( $+functions[_systemctl_command] )) || _systemctl_command() { @@ -326,12 +353,15 @@ _outputmodes() { "restart:Start or restart one or more units" "condrestart:Restart one or more units if active" "try-restart:Restart one or more units if active" - "reload-or-restart:Reload one or more units is possible, otherwise start or restart" - "force-reload:Reload one or more units is possible, otherwise restart if active" - "reload-or-try-restart:Reload one or more units is possible, otherwise restart if active" + "reload-or-restart:Reload one or more units if possible, otherwise start or restart" + "force-reload:Reload one or more units if possible, otherwise restart if active" + "hibernate:Hibernate the system" + "hybrid-sleep:Hibernate and suspend the system" + "reload-or-try-restart:Reload one or more units if possible, otherwise restart if active" "isolate:Start one unit and stop all others" "kill:Send signal to processes of a unit" "is-active:Check whether units are active" + "is-failed:Check whether units are failed" "status:Show runtime status of one or more units" "show:Show properties of one or more units/jobs or the manager" "reset-failed:Reset failed state for all, one, or more units" @@ -341,6 +371,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" @@ -348,7 +380,6 @@ _outputmodes() { "list-jobs:List jobs" "cancel:Cancel all, one, or more jobs" "dump:Dump server status" - "dot:Dump dependency graph for dot(1)" "snapshot:Create a snapshot" "delete:Remove one or more snapshots" "show-environment:Dump environment" @@ -398,7 +429,9 @@ _outputmodes() { __systemctl() { - systemctl --full --no-legend --no-pager "$@" + local -a _modes + _modes=("--user" "--system") + systemctl ${words:*_modes} --full --no-legend --no-pager "$@" } @@ -408,7 +441,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 } @@ -421,7 +454,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}) @@ -441,20 +474,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-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 @@ -467,7 +500,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 @@ -527,7 +561,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 @@ -550,7 +584,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 @@ -564,14 +598,14 @@ 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 (( $+functions[_systemctl_link] )) || _systemctl_link() { _files } # no systemctl completion for: -# [STANDALONE]='daemon-reexec daemon-reload default dot dump +# [STANDALONE]='daemon-reexec daemon-reload default dump # emergency exit halt kexec list-jobs list-units # list-unit-files poweroff reboot rescue show-environment' # [NAME]='snapshot load' @@ -603,6 +637,7 @@ _list_fields() { _{P,U,G}ID _COMM _EXE _CMDLINE _AUDIT_{SESSION,LOGINUID} _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID} + _SYSTEMD_USER_UNIT _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT _KERNEL_{DEVICE,SUBSYSTEM} @@ -611,18 +646,27 @@ _list_fields() { _describe 'possible fields' journal_fields } +_journal_none() { + local -a _commands _files + _commands=( ${(f)"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} ) + _alternative : \ + 'files:/dev files:_files -W /dev -P /dev/' \ + "commands:commands:($_commands[@])" \ + 'fields:fields:_list_fields' +} + _journal_fields() { local -a _fields cmd cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" ) - _fields=( ${(f)"$(_call_program fields $cmd[@])"} ) + _fields=( ${(f)"$(_call_program fields $cmd[@])"} ) typeset -U _fields _describe 'possible values' _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 @@ -771,8 +815,8 @@ _localectl_set-x11-keymap() { #_model=( ${(f)"$(echo $_file[2] | awk '/^ / {print $1}')"} ) #_variant=( ${(f)"$(echo $_file[3] | awk '/^ / {print $1}')"} ) #_options=( ${(f)"$(echo ${_file[4]//:/\\:} | awk '/^ / {print $1}')"} ) - - case $CURRENT in + + case $CURRENT in 2) _describe layouts _layout ;; 3) _describe models _model;; 4) _describe variants _variant;; @@ -870,12 +914,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 @@ -887,6 +932,38 @@ _systemd-coredumpctl_command(){ } +(( $+functions[_machinectl_command] )) || _machinectl_command() +{ + local -a _machinectl_cmds + _machinectl_cmds=( + "list:List currently running VMs/containers" + "status:Show VM/container status" + "show:Show properties of one or more VMs/containers" + "terminate:Terminate one or more VMs/containers" + "kill:Send signal to process or a VM/container" + ) + if (( CURRENT == 1 )); then + _describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@" + else + local curcontext="$curcontext" + cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}" + if (( $#cmd )); then + case $cmd in + list) msg="no options" ;; + *) + _machines=( "${(foa)$(machinectl list | awk '{print $1}')}" ) + if [[ -n "$_machines" ]]; then + _describe 'machines' _machines + else + _message 'no machines' + fi + esac + else + _message "no more options" + fi + fi +} + _udevadm_info(){ _arguments \ '--query=[Query the database for specified type of device data. It needs the --path or --name to identify the specified device.]:type:(name symlink path property all)' \ @@ -939,13 +1016,13 @@ _udevadm_control(){ '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \ '--help[Print help text.]' } - + _udevadm_monitor(){ _arguments \ '--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.]' } @@ -962,7 +1039,7 @@ _udevadm_test-builtin(){ if (( CURRENT == 2 )); then _arguments \ '--help[Print help text]' \ - '*::builtins:(blkid btrfs firmware hwdb input_id kmod path_id usb_id uaccess)' + '*::builtins:(blkid btrfs hwdb input_id kmod path_id usb_id uaccess)' elif (( CURRENT == 3 )); then _arguments \ '--help[Print help text]' \