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

Zsh support? #35

Open
borekb opened this issue Apr 9, 2019 · 6 comments
Open

Zsh support? #35

borekb opened this issue Apr 9, 2019 · 6 comments

Comments

@borekb
Copy link

borekb commented Apr 9, 2019

Hi, I don't know how completions work internally and whether completions for Zsh are something completely different than completions for Bash but it would be awesome if this package worked in both shells. Is that technically possible?

BTW, these Yarn completions are way more advanced than anything else I have seen (for zsh at least), for example, parsing workspaces from package.json as per #29 is the right thing to do while most other completions don't support Yarn workspaces at all.

@dsifford
Copy link
Owner

dsifford commented Apr 9, 2019

Officially supported zsh completions can be found here.

Unfortunately, the completions for bash and zsh are implemented in an entirely different way, so there's no real great way to interop (that I'm aware of).

See #30 for discussion on some issues with parsing workspaces using package.json.

@dsifford dsifford closed this as completed Apr 9, 2019
@borekb
Copy link
Author

borekb commented Apr 9, 2019

For anyone interested, I managed to make it work this way:

  1. Add this shopt script somewhere in your $PATH.
  2. autoload bashcompinit && bashcompinit
  3. source yarn-completion.bash

Screenshot 2019-04-09 at 19 16 46

@borekb
Copy link
Author

borekb commented Apr 12, 2019

@dsifford if you don't mind I'll use this issue to gather pieces of information about the possible Zsh support. (Disclaimer: I know very little about how the completions work internally in either Bash or Zsh so won't probably be able to help myself.)

Current situation:

What I found in Zsh docs is simply this:

The function bashcompinit provides compatibility with bash’s programmable completion system. When run it will define the functions, compgen and complete which correspond to the bash builtins with the same names. It will then be possible to use completion specifications and functions written for bash.

I also have zsh-users/zsh-completions installed which has this file in it, which seems to implement the compgen and complete functions as well. I'm not sure if it's loaded and how, and how it interacts with the built-in bashcompinit from Zsh.

I also don't know how to troubleshoot issues with autocompletion – the suggestions are simply weird but there are no error messages anywhere.

@dsifford
Copy link
Owner

@borekb Open up a new issue so others can find it easier. That way we might get lucky and have someone stumble upon it and help.

Re: your disclaimer -- I had no idea how bash completions worked and have never wrote a bash completion script in my life prior to making this one. It's tricky at first to understand, but I'm proof that it's possible. Don't sell yourself short.

@borekb
Copy link
Author

borekb commented Apr 12, 2019

If it was writing completions for a single known environment, maybe I could try to do that but this sounds like troubleshooting of some (delicate?) interactions / integrations between Zsh and Bash which I really don't think I'd be capable of 😄.

How about re-opening this issue? "Zsh support" as a title sounds pretty good to me.

@dsifford
Copy link
Owner

Whoops, sorry... Thought this was the PR I commented on.

Yep, we can reopen this one. 👍

@dsifford dsifford reopened this Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants