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

feat(completion): support sourcing zsh completion dynamically #2957

Merged
merged 2 commits into from
Dec 31, 2024

Conversation

vegerot
Copy link
Contributor

@vegerot vegerot commented Dec 30, 2024

Summary:
Previously, you needed to save the completion script to a file and then
source it. Now, you can dynamically source completions in zsh by
running

$ source <(rg --generate complete-zsh)

Test plan:

  1. Run source <(rg --generate complete-zsh)
  2. Run rg --generate=complete-zs<TAB>

Before this commit, you would get an error after step 1.
After this commit, it should work as expected.

Closes #2956

@vegerot vegerot force-pushed the vegerot/source_completion branch 3 times, most recently from 78e7e1a to 1b28717 Compare December 30, 2024 23:45
Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r? @okdana

FAQ.md Show resolved Hide resolved
@vegerot vegerot force-pushed the vegerot/source_completion branch from 1b28717 to a7de1f8 Compare December 31, 2024 00:23
FAQ.md Show resolved Hide resolved
Summary:
Previously, you needed to save the completion script to a file and then
source it.  Now, you can dynamically source completions in zsh by
running

```zsh
$ source <(rg --generate complete-zsh)
```

Test plan:
1. Run `source <(rg --generate complete-zsh)`
2. Run `rg --generate=complete-zs<TAB>`

Before this commit, you would get an error after step 1.
After this commit, it should work as expected.

Closes BurntSushi#2956
@vegerot vegerot force-pushed the vegerot/source_completion branch from a7de1f8 to 7c2a7b0 Compare December 31, 2024 01:01
@BurntSushi
Copy link
Owner

I've left it in the FAQ and fixed up the wording by adding an appropriate caveat emptor. I guess since other projects have found it useful to suggest this method it's probably not too big of a deal for ripgrep to do it too. But the text now makes it clear that the "generate and source" approach is slower. 4ms might not seem like much, and indeed, I cannot perceive a 4ms lag, but if you accrue 10 of those kinds of things, it starts to pile up into something that is noticeable.

@BurntSushi BurntSushi merged commit 9430512 into BurntSushi:master Dec 31, 2024
18 checks passed
@vegerot
Copy link
Contributor Author

vegerot commented Jan 3, 2025

@BurntSushi I'm using a self-built version now, but jooc when will the next release be so others can use it?

@BurntSushi
Copy link
Owner

I don't know, sorry. See: https://github.com/BurntSushi/ripgrep/blob/master/FAQ.md#when-is-the-next-release

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

Successfully merging this pull request may close these issues.

Can't source zsh completions directly
3 participants