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 zsh autocompletion #86

Merged
merged 1 commit into from
Aug 27, 2019
Merged

Add zsh autocompletion #86

merged 1 commit into from
Aug 27, 2019

Conversation

ma-renaud
Copy link
Contributor

It's my first attempt at a zsh completion file. Let me know if some changes are needed.

@dbrgn
Copy link
Collaborator

dbrgn commented Aug 26, 2019

I'm not a zsh user myself Can you find someone that can test this PR?

Also, I'm on my mobile right now and can't check, but I think there is a lot of duplication with the bash completion, right? Maybe the configs could be shared somehow? Potentially tealdeer could even generate the completion file(s) on demand.

@ma-renaud
Copy link
Contributor Author

I will ask a friend of mine (@Jarhmander) who also use zsh.

Concerning the duplication, the structure of the file is similar, but the mechanics are not the same between bash and zsh.

Do you plan on adding a lot of new options to the software? If yes, I can take a look at rust to see how the files can be generated from the available options.

@Jarhmander
Copy link

Here's what it does on my machine when I type tldr - followed by a tab:

james@james-cimeq ~ % tldr -Cache not found. Please run `tldr --update`.
                      tldr -█
completing option
--clear-cache  -c  -- Clear the local cache                                                                                                                                                  
--config-path      -- Show config file path                                                                                                                                                  
--help         -h  -- Display help                                                                                                                                                           
--list         -l  -- List all commands in the cache                                                                                                                                         
--os           -o  -- Override the operating system                                                                                                                                          
--pager        -p  -- Use a pager to page output                                                                                                                                             
--quiet        -q  -- Suppress informational messages                                                                                                                                        
--render       -f  -- Render a specific markdown file                                                                                                                                        
--seed-config      -- Create a basic config                                                                                                                                                  
--update       -u  -- Update the local cache                                                                                                                                                 
--version      -v  -- Show version information 

(I showed where the caret is with )

So it visually glitches out a little because there were no cache when I tried it, but otherwise nothing harmful here. Once the cache is updated (as requested by the program) it acts normally, except that when I "tab" after a dash, it actually suggest all the applications with the options as well.

@dbrgn
Copy link
Collaborator

dbrgn commented Aug 27, 2019

Concerning the duplication, the structure of the file is similar, but the mechanics are not the same between bash and zsh.

Ok, then let's keep it for now. In the long run I'd like to generate those completion files.

For docopt (which we use right now) there doesn't seem to be a nice solution, but I'd like to switch to clap anyways. And clap supports generating completions for various shells!

@Jarhmander thanks for testing!

@dbrgn dbrgn merged commit ece174e into tealdeer-rs:master Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants