Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add completion for popular shells #629

Closed
3 tasks
linozen opened this issue Nov 23, 2022 · 6 comments
Closed
3 tasks

Add completion for popular shells #629

linozen opened this issue Nov 23, 2022 · 6 comments
Labels
discussion needed enhancement New feature or request

Comments

@linozen
Copy link
Contributor

linozen commented Nov 23, 2022

It would be really nice to have completion for all the popular shells such as:

  • bash
  • zsh
  • fish
@linozen linozen added enhancement New feature or request discussion needed labels Nov 23, 2022
@linozen linozen changed the title Track completion for popular shells Add completion for popular shells Nov 23, 2022
@nicorikken
Copy link
Member

Ideally instrument it in a way that parameters in Python and completions can easily be kept in sync to prevent drift. One option is to generate them from the argparse definitions. Another approach can be to generate them from the helpfile or manpage as some external tools do. For Zsh at least it is worth considering a mechanism of installing completions.

@rpatterson
Copy link

Perhaps argcomplete?

evelikov added a commit to evelikov/reuse-tool that referenced this issue Sep 22, 2024
Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
python-shtab. Unlike other solutions which repeatedly invoke the
underlying program, to retrieve the next suggestion, shtab parses
argparse options and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
evelikov added a commit to evelikov/reuse-tool that referenced this issue Sep 22, 2024
Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
python-shtab. Unlike other solutions which repeatedly invoke the
underlying program, to retrieve the next suggestion, shtab parses
argparse options and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
@evelikov
Copy link
Contributor

#1076 should address this in a somewhat elegant manner IMHO.

evelikov added a commit to evelikov/reuse-tool that referenced this issue Sep 22, 2024
Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
python-shtab. Unlike other solutions which repeatedly invoke the
underlying program, to retrieve the next suggestion, shtab parses
argparse options and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
evelikov added a commit to evelikov/reuse-tool that referenced this issue Sep 22, 2024
Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
python-shtab. Unlike other solutions which repeatedly invoke the
underlying program, to retrieve the next suggestion, shtab parses
argparse options and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
evelikov added a commit to evelikov/reuse-tool that referenced this issue Sep 22, 2024
Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
python-shtab. Unlike other solutions which repeatedly invoke the
underlying program, to retrieve the next suggestion, shtab parses
argparse options and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
evelikov added a commit to evelikov/reuse-tool that referenced this issue Sep 22, 2024
Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
python-shtab. Unlike other solutions which repeatedly invoke the
underlying program, to retrieve the next suggestion, shtab parses
argparse options and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
evelikov added a commit to evelikov/reuse-tool that referenced this issue Sep 23, 2024
Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
python-shtab. Unlike other solutions which repeatedly invoke the
underlying program, to retrieve the next suggestion, shtab parses
argparse options and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
carmenbianca added a commit to evelikov/reuse-tool that referenced this issue Sep 26, 2024
Having a shell completion improves developers' workflow and makes it
easier for everyone to notice as the program gains new options.

This commit adds support for generatic static completion files via
shtab. Unlike other solutions which repeatedly invoke the underlying
program, to retrieve the next suggestion, shtab parses argparse options
and produces a complete static file.

It currently supports bash, tcsh and bash with PR opened for fish
support. For example, to generate zsh completion use:
 - reuse --print-completion zsh > /usr/share/zsh/site-functions/_reuse

This can be done by the reuse project itself, the package maintainer or
end-user.

For more details, see https://github.com/iterative/shtab

Closes: fsfe#629
Co-authored-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com
@rpatterson
Copy link

FWIW, I wish Re-use also implemented argcomplete completion and allowed users to chose between speed and more automatic completion. For example, if it did implement argcomplete, I would get tab completion on my system without any changes other than the code changes in re-use because I already have /etc/bash_completion.d/python-argcomplete installed. It's pretty trivial.

@carmenbianca
Copy link
Member

@rpatterson Can you open a new issue for this? I am not intensely familiar with argcomplete (nor shtab, for that matter).

Can they be used in parallel?

@rpatterson
Copy link

Can you open a new issue for this?

Done, @carmenbianca, but I was really just sharing an opinion and alternate use case for posterity. It's not worth much of your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion needed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants