From: Ronan Pigott Date: Sun, 26 Oct 2025 04:04:03 +0000 (-0700) Subject: zsh: add completion for dbus bus address X-Git-Tag: v259-rc1~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f8e6e50a0e3901e347840c323b1b450945d047a;p=thirdparty%2Fsystemd.git zsh: add completion for dbus bus address The DBUS_SESSION_BUS_ADDRESS and DBUS_SYSTEM_BUS_ADDRESS parameters have an interesting syntax thats useful to complete. Let's include a completion definition for these parameters. --- diff --git a/shell-completion/zsh/_sd_bus_address b/shell-completion/zsh/_sd_bus_address new file mode 100644 index 00000000000..a3b91050cb7 --- /dev/null +++ b/shell-completion/zsh/_sd_bus_address @@ -0,0 +1,50 @@ +#compdef -value-,DBUS_SESSION_BUS_ADDRESS,-default- -value-,DBUS_SYSTEM_BUS_ADDRESS,-default- + +local context state state_descr line +typeset -A val_args + +_values -S: kind \ + 'unix[a unix domain socket]:unix properties:->unix' \ + 'tcp[a tcp socket]:tcp properties:->tcp' \ + 'unixexec[a process]:unixexec properties:->unixexec' \ + 'x-machine-unix[a container]:machine properties:->x-machine-unix' + +_sd_bus_get_guid() { + local TYPE VALUE + local -a busname=(org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus) + + _call_program -l dbus-guid busctl call $busname GetId | + while read TYPE VALUE; do + [[ $TYPE == 's' && -n $VALUE ]] && compadd "$@" - ${(Q)VALUE}; + done +} + +local expl ret +case $context in + unix) + _values -s, 'unix socket properties' \ + 'guid[bus guid]:bus guid:_sd_bus_get_guid -qS,' \ + '(abstract)path[unix domain socket path]:path:_files -r, -g "*(=)"' \ + '(path)abstract[unix domain socket path in the abstract namespace]:abstract path:_files -r, -P@ -g "*(=)"' \ + 'uid[unix uid]:uid:_numbers' \ + 'gid[unix gid]:gid:_numbers' + ;; + tcp) + _values -s, 'unix socket properties' \ + 'guid[bus guid]:bus guid:_sd_bus_get_guid -qS,' \ + 'host[hostname]:hostname:_hosts -r,'\ + 'port[port]:port:_numbers' \ + 'family[address family]:address family:(ipv4 ipv6)' + ;; + unixexec) + _values -s, 'unixexec properties' \ + 'guid[bus guid]:bus guid:_sd_bus_get_guid -qS,' \ + 'path[command path]:command path:_absolute_command_paths -r,'\ + ;; + x-machine-unix) + _values -s, 'machine properties' \ + 'guid[bus guid]:bus guid:_sd_bus_get_guid -qS,' \ + '(pid)machine[machine]:machine:_call_function ret _sd_machines' \ + '(machine)pid[pid]:pid:_pids' + ;; +esac diff --git a/shell-completion/zsh/meson.build b/shell-completion/zsh/meson.build index e4252c7097b..4de28388ce8 100644 --- a/shell-completion/zsh/meson.build +++ b/shell-completion/zsh/meson.build @@ -24,6 +24,7 @@ items = [['_busctl', ''], ['_udevadm', ''], ['_varlinkctl', ''], ['_kernel-install', 'ENABLE_KERNEL_INSTALL'], + ['_sd_bus_address', ''], ['_sd_hosts_or_user_at_host', ''], ['_sd_outputmodes', ''], ['_sd_unit_files', ''],