Skip to content

Add zsh device autocompletion helper

Summary

This adds a new command line flag to kdeconnect-cli, --zsh-device-autocomplete, which outputs device ID's and descriptions. This allows zsh to show the device name and paired status during autocompletion. An example:

screenshot

(The second line is not a real device, just added to show the autocomplete menu.)

I implemented this in kdeconnect-cli instead of zsh, because this handles all corner cases regarding invalid characters correctly.

Test Plan

You can see the generated output yourself by running kdeconnect-cli --zsh-device-autocomplete. Note that the flag is hidden in the --help output, because it's not meant to be used by users directly.

The autocompletion requires some changes on zsh's side, which I plan on doing after a KDE Connect release. To test those yourself, change _kdeconnect_device-ids in /usr/share/zsh/functions/Completion/X/_kdeconnect to:

_kdeconnect_device-ids() {
  _values "KDE Connect device id" "${(f)$(kdeconnect-cli --zsh-device-autocomplete)}"
}

Merge request reports

Loading