Discussion:
dh-shell-completions: simple debhelper addon to install shell completions
(too old to reply)
Blair Noctis
2025-03-16 18:50:02 UTC
Permalink
Hi -devel,

Kind of a shameless plug, but enough people said it's useful so I thought might as well let more know.

I'll not go into great details, because there isn't any. Just check its man page and source code:
https://manpages.debian.org/unstable/dh-shell-completions/dh_shell_completions.1.en.html
https://salsa.debian.org/debian/dh-shell-completions

Some examples:
https://salsa.debian.org/debian/atuin/-/blob/debian/sid/debian/atuin.shell-completions
https://salsa.debian.org/rust-team/starship/-/blob/debian/sid/debian/starship.shell-completions

Testing and improvements welcome!

--
Sdrager,
Blair Noctis
M. Zhou
2025-03-16 19:20:01 UTC
Permalink
Post by Blair Noctis
Kind of a shameless plug, but enough people said it's useful so I thought might as well let more know.
https://manpages.debian.org/unstable/dh-shell-completions/dh_shell_completions.1.en.html
https://salsa.debian.org/debian/dh-shell-completions
Thank you for this dh module! After browsing the examples, I came up with
an old problem about these completion scripts -- whether the completions
should be loaded by default, and whether that behavior should be synced
among shells.

Do you think it is useful to define some flags for
dh_shell_completions, like --enable-by-default, --disable-by-default
to decide whether a completion file should be enabled by default.

I'm raising this question because I find it somewhat confusing
because different shells do the completions and keybindings in very
different ways. For instance, fzf:
https://salsa.debian.org/go-team/packages/fzf/-/blob/master/debian/README.Debian

As you can see, key-binding scripts are similar to completion scripts.
Maybe they can be dealt by the same dh module as well. Generally
key-binding scripts should not be enabled by default due to potential
conflicts.

A quick search suggests that both policy and devref do not cover
the shell integration topic.

An example that resembles what I'm talking about is dh_installsystemd.
It has --no-enable, --restart-after-upgrade, --no-restart-after-upgrade,
etc flags to control the systemd unit behavior upon dpkg actions.
Blair Noctis
2025-03-18 10:40:01 UTC
Permalink
Post by M. Zhou
Post by Blair Noctis
Kind of a shameless plug, but enough people said it's useful so I thought might as well let more know.
https://manpages.debian.org/unstable/dh-shell-completions/dh_shell_completions.1.en.html
https://salsa.debian.org/debian/dh-shell-completions
Thank you for this dh module! After browsing the examples, I came up with
an old problem about these completion scripts -- whether the completions
should be loaded by default, and whether that behavior should be synced
among shells.
Completions are static (relative to a specific version of the program).
There seems no need to modify them.
There seems no need to disable them.
They don't seem to cause harm.
So I don't think enabling them by default would cause any trouble.

Different shells could have different conventions.
But the status quo is, to my knowledge,
most packages just install completions as immediately enabled.
I don't think such differences, even if they exist, matter anymore.
Post by M. Zhou
Do you think it is useful to define some flags for
dh_shell_completions, like --enable-by-default, --disable-by-default
to decide whether a completion file should be enabled by default.
I'm raising this question because I find it somewhat confusing
because different shells do the completions and keybindings in very
https://salsa.debian.org/go-team/packages/fzf/-/blob/master/debian/README.Debian
As you can see, key-binding scripts are similar to completion scripts.
Maybe they can be dealt by the same dh module as well. Generally
key-binding scripts should not be enabled by default due to potential
conflicts.
At a glance yes.

But install keybindings where?
Shells have standard locations in which completions are immediately enabled.
Keybindings obviously shouldn't be immediately enabled.
But are there such standard locations for "disabled" keybindings?
Your example didn't show existence of such.
If not, where should we install them to?
Maybe we can install them as docs or examples,
but then a debian/$package.{docs/examples} would do.

Also, the package name is already there.
I'd rather something named "shell-completions",
not handle things other than, well, shell completions.
Post by M. Zhou
A quick search suggests that both policy and devref do not cover
the shell integration topic.
An example that resembles what I'm talking about is dh_installsystemd.
It has --no-enable, --restart-after-upgrade, --no-restart-after-upgrade,
etc flags to control the systemd unit behavior upon dpkg actions.
There are also packages with service definitions that can't be used as is.
Or even unwanted by the user.
They can at most be installed as docs or examples.
IMO this situation is akin to keybinding scripts.

--
Sdrager,
Blair Noctis
Jonas Smedegaard
2025-03-18 11:30:01 UTC
Permalink
Quoting Blair Noctis (2025-03-18 11:35:21)
Post by Blair Noctis
Post by M. Zhou
Do you think it is useful to define some flags for
dh_shell_completions, like --enable-by-default, --disable-by-default
to decide whether a completion file should be enabled by default.
I agree with Blair that shell-completions need no enablement mechanism.
Changing subject accordingly for this subtread.
Post by Blair Noctis
Post by M. Zhou
I'm raising this question because I find it somewhat confusing
because different shells do the completions and keybindings in very
https://salsa.debian.org/go-team/packages/fzf/-/blob/master/debian/README.Debian
As you can see, key-binding scripts are similar to completion scripts.
Maybe they can be dealt by the same dh module as well. Generally
key-binding scripts should not be enabled by default due to potential
conflicts.
At a glance yes.
But install keybindings where?
Shells have standard locations in which completions are immediately enabled.
Keybindings obviously shouldn't be immediately enabled.
But are there such standard locations for "disabled" keybindings?
Your example didn't show existence of such.
If not, where should we install them to?
Maybe we can install them as docs or examples,
but then a debian/$package.{docs/examples} would do.
Regardless of whether keybindings get covered by dh-shell-completions
or end in an independent dh-keybndings package or whatever, I agree that
first some common pattern of how such assets might be organised in the
filesystem needs to be established first - either from current praxis
(which keybindings already get installed today in existing packages?)
or from committee.

I am not even sure what "keybindings" cover, and doubt that any of the
700+ packages I am involved in provides any, so I will leave the details
to those actually involved in needing infrastructure for such assets.

One more general remark, though: Do *not* rely on assets located below
/usr/share/doc - e.g. don't package some asset there and instruct users
to symlink that asset to somewhere "inside" the core system, because
the system must not rely on that path existing on a system at all
(I think it is covered in Debian Policy somewhere, just too lazy to look
right now). Instead, place assets e.g. below /usr/share/<PKG>/ - or if
you really must put it as part of the documentation then make sure to
only ever instruct to *copy* the asset elsewhere (which is most likely a
bad idea for maintenance of such system).

- Jonas
--
* Jonas Smedegaard - idealist & Internet-arkitekt
* Tlf.: +45 40843136 Website: http://dr.jones.dk/
* Sponsorship: https://ko-fi.com/drjones

[x] quote me freely [ ] ask before reusing [ ] keep private
Matthias Geiger
2025-03-16 19:30:01 UTC
Permalink
Hi all,
Post by Blair Noctis
Kind of a shameless plug, but enough people said it's useful so I
thought might as well let more know.
I'll not go into great details, because there isn't any. Just check
thanks to ncts for writing this. Am a very happy user of this.
To expand a bit on the functionality:
dh-shellcompletions automatically generates the completion files for the
respective shells (if the binary has this built-in as subcommand) and
installs in into the correct dirs.
.
No more d/rules hacks needed.

best,

werdahias
Nicolas Peugnet
2025-03-16 21:50:01 UTC
Permalink
Hi,
Post by Blair Noctis
Kind of a shameless plug, but enough people said it's useful so I
thought might as well let more know.
I'll not go into great details, because there isn't any. Just check its
https://manpages.debian.org/unstable/dh-shell-completions/
dh_shell_completions.1.en.html
https://salsa.debian.org/debian/dh-shell-completions
Honestly, I found about it after looking for exactly this, and it is a
perfect match for my (yet to be released) crazy-complete package:
https://salsa.debian.org/debian/crazy-complete/-/commit/4be5615207a4b8f21918240d9e2673e8c3ecd2e4

I just wanted to say thank you for creating this.
--
Nicolas Peugnet
Loading...