From: Ronan Pigott Date: Sun, 1 Mar 2026 16:47:16 +0000 (-0700) Subject: zsh: add systemd-id128 completions X-Git-Tag: v260-rc2~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8d720dea869b36001befb565a9149a82f66de19b;p=thirdparty%2Fsystemd.git zsh: add systemd-id128 completions --- diff --git a/shell-completion/zsh/_systemd-id128 b/shell-completion/zsh/_systemd-id128 new file mode 100644 index 00000000000..2cc06de80b0 --- /dev/null +++ b/shell-completion/zsh/_systemd-id128 @@ -0,0 +1,55 @@ +#compdef systemd-id128 + +local context state state_descr line +typeset -A opt_args +local expl + +local -a opt_common=( + {-h,--help}'[show a help message and exit]' + '--no-pager[do not pipe output into a pager]' + '--no-legend[do not show the headers and footers]' + '(-j)--json=[output inspection data in json format]:json-mode:(pretty short off)' + '(--json)-j[equivalent to --json=short or --json=pretty on TTY]' + '-p[generate samples of program code]' + '(-P --value)'{-P,--value}'[only print the value]' + '(-a --app-specific)'{-a+,--app-specific=}'[generate app-specific IDs]' + '(-u --uuid)'{-u,--uuid}'[output in uuid format]' +) + +local -a id128_commands=( + 'new:generate a new id' + 'machine-id:print the id of the current machine' + 'boot-id:print the id of the current boot' + 'invocation-id:print the id of the current invocation' + 'var-partition-uuid:print the uuid of the /var partition' + 'show:print one or more uuids' +) + +_systemd-id128_names() { + local expl + local -a names=( ${${(@f)"$(_call_program -l id128-name systemd-id128 show)"}%% *} ) + _wanted id128-name expl "name" compadd "$@" -a - names +} + +local ret=1 +_arguments -s "$opt_common[@]" \ + ':command:->command' \ + '*:: :->option-or-argument' && ret=0 + +case $state in + command) + _describe -t command 'id128 command' id128_commands && ret=0 + ;; + option-or-argument) + local curcontext=${curcontext%:*:*}:systemd-id128-$words[1]: + case $words[1] in + *-id) + _arguments -s "$opt_common[@]" && ret=0 + ;; + show) + _arguments -s "$opt_common[@]" ':name:_systemd-id128_names' && ret=0 + ;; + esac + ;; +esac +return ret diff --git a/shell-completion/zsh/meson.build b/shell-completion/zsh/meson.build index bcd7899a153..c5ee8d43a90 100644 --- a/shell-completion/zsh/meson.build +++ b/shell-completion/zsh/meson.build @@ -36,6 +36,7 @@ foreach item : [ ['_systemd', ''], ['_systemd-analyze', ''], ['_systemd-delta', ''], + ['_systemd-id128', ''], ['_systemd-inhibit', 'ENABLE_LOGIND'], ['_systemd-nspawn', ''], ['_systemd-path', ''],