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 autocomplete #1

Open
squarism opened this issue Mar 12, 2015 · 8 comments
Open

zsh autocomplete #1

squarism opened this issue Mar 12, 2015 · 8 comments

Comments

@squarism
Copy link

I saw the note about making a PR to confirm that it works for zsh users. I couldn't get it to work so I'm opening an issue to help document and assist. :)

I think the problem is that zsh doesn't have COMP_LINE. So an exception is thrown on a nil value. Manually setting COMP_LINE fixes it but the actual value obviously needs to be dynamic for it to be useful.

  # ... <TAB><TAB>
  minitest ~/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/shellwords.rb:73:in `shellsplit': undefined method 
   `scan' for nil:NilClass (NoMethodError)
  from ~/.rvm/gems/ruby-2.1.5/gems/minitest-sprint-1.1.0/lib/minitest/complete.rb:8:in `<main>'

I then tried to get the bash compatibility options to work with zsh but my initial attempts have failed. This is in the context of oh-my-zsh. So maybe a vanilla zsh user would have more luck with their .zshrc config. I think a good solution would be to write a oh-my-zsh plugin and change minitest/complete.rb to handle whatever environment differences are between the two shells. But I haven't figured this out yet. I took at stab at a zsh plugin but I need to work on it some more.

I switched to bash temporarily to get the happy path working and developed against that state. Of course it works. :) So, this is definitely zsh related. I'm hoping I can contribute something more substantial.

@zenspider
Copy link
Contributor

Awesome! Thanks! I'll get some ppl from IRC to put eyeballs on this.

@baweaver
Copy link

@baweaver
Copy link

I switched to Bash but didn't have the env variable in either one. What is it normally?

@zenspider
Copy link
Contributor

zsh code of interest:

% _mycompleter() { read -l; local cl="$REPLY"; read -ln; local cp="$REPLY"; reply=(`COMP_SHELL=zsh COMP_LINE="$cl" COMP_POINT="$cp" mycompleter`) }
% compctl -K _mycompleter someprog

vs bash:

complete -C mycompleter someprog

where mycompleter is an external command in bash, but can't be in zsh.

@baweaver
Copy link

Yeah, that sites pre tags have hidden overflows, so fair warning.

@squarism
Copy link
Author

COMP_LINE gets evaluated when you hit <TAB><TAB> in bash. You can see it if you just putsit in the minitest/complete.rb For example, it's probably minitest -n test_ if you follow the (bash) README. I think a port (like the _mycompleter function you mention up there) would work if you could get bash compatibility to work. I tried a few different ways but couldn't get the COMP_LINE to show up anywhere.

So then I switched to trying to get a zsh plugin (specifically oh-my-zsh) to work. But I've never written one so it's trial-by-fire. 🔥 😄

@zenspider zenspider self-assigned this Apr 11, 2015
@zenspider zenspider removed their assignment Apr 25, 2015
@zenspider
Copy link
Contributor

Unassigning so people might be encouraged to help on this more.

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

3 participants