Nukesor / pueue

:stars: Manage your shell commands.
MIT License
4.69k stars 128 forks source link

Write generated completion script to stdout if directory is not provided as an argument #489

Closed mcarifio closed 5 months ago

mcarifio commented 5 months ago

A detailed description of the feature you would like to see added.

First, ty for pueue. Nushell is less usable without it.

pueue completions bash /tmp will generate a bash completion script /tmp/pueue.bash (for example). If no directory is provided, no completion script is generated. It would be useful if pueue completions bash output the completion script to stdout. Then in bash one could write: source <(pueue completions bash) without persisting intermediate files. This is particularly useful when installing new versions of pueue. It will keep the exe and completions in sync always.

I understand pueue is feature complete and the completion script won't change very often. Until it does and older copies are getting sourced and users (like me) get confused.

Explain your usecase of the requested feature

See above. I do note that /usr/share/bash-completion/completions/pueue is created and since it's installed with pueue that might solve the coordination concern.

Alternatives

I wrote a bash script to generate the completion script and source it when I log in:

pueue.complete() {
    local _tmp=$(mktemp --directory /tmp/${USER}-pueue-completions-XXXXX)
    local _shell=bash
    pueue completions ${_shell} ${_tmp}
    source ${_tmp}/pueue.${_shell}    && rm -rf ${_tmp}
}; pueue.complete

This works. It's a little janky.

Additional context

This is a "nice to have" for bash and zsh users. I don't know how other shells handle sourcing code from another process.

Nukesor commented 5 months ago

I think that's a reasonable QoL adjustment :)

Usually, completion files should be deployed by the distribution's package manager, but pueue sadly hasn't been packaged for some of the bigger distros yet (fedora, debian)

mcarifio commented 5 months ago

fc39 packages 3.0 I think, which has issues generating a sourceable completion script. I installed 3.2 manually and my janky script above will serve for now. Good devs don't let users drive jank (that's reachin', Seinfeld I ain't). Ty.

Nukesor commented 5 months ago

Also good packagers should be up-to-date with upstream :)

This project adheres to semver and there's no reason for stuff not being up-to-date on fedora's side until a v4 is released (unless I don't know some specifics about Fedora's packaging guidelines, which might very much be the case)

As I already said above, this is still a nice QoL improvement and It should be fairly easy to implement.