Skip to content
New issue

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

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

Already on GitHub? # to your account

shell completion should behave uniformly for bash and zsh when sourced #986

Closed
srlehn opened this issue Nov 7, 2019 · 5 comments
Closed

Comments

@srlehn
Copy link

srlehn commented Nov 7, 2019

I was under the assumption that because . <(app genshcomp) ("app genshcomp" returns shell completion code) worked for bash that the generated zsh code should behave the same for zsh. I can't see any reason to block this behaviour for zsh if only a single line has to be added (#887).

For my portable application I value the ability to directly inject the completion code into the running shell without having to save a temporary file or additional commands.

I suggest reopening #887, at least for me it works fine.

@corneliusweig
Copy link

Big 👍

@github-actions
Copy link

github-actions bot commented Apr 3, 2020

This issue is being marked as stale due to a long period of inactivity

@marckhouzam
Copy link
Collaborator

This article gives some reason why sourcing a completion script isn't great: https://medium.com/@jzelinskie/please-dont-ship-binaries-with-shell-completion-as-commands-a8b1bcb8a0d0

That being said, what you can do is add the missing compdef line to your .zshrc (or something of the sort) and then sourcing the completion file will work.

@marckhouzam
Copy link
Collaborator

I believe @jharshman has confirmed he prefers to follow zsh's best practices and not include the compdef line in the script: #1070 (comment)

The program using Cobra can easily choose to add this line itself.

@jharshman I believe we can close this issue.

@jharshman
Copy link
Collaborator

Yes, that is correct @marckhouzam. Closing this issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants