mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-04 21:52:54 +02:00
zsh: support sourcing zsh completion dynamically
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) Before this commit, you would get an error after step 1. After this commit, it should work as expected. We also improve the FAQ item for zsh completions. Fixes #2956
This commit is contained in:
@ -434,7 +434,15 @@ _rg_types() {
|
||||
fi
|
||||
}
|
||||
|
||||
_rg "$@"
|
||||
# Don't run the completion function when being sourced by itself.
|
||||
#
|
||||
# See https://github.com/BurntSushi/ripgrep/issues/2956
|
||||
# See https://github.com/BurntSushi/ripgrep/pull/2957
|
||||
if [[ $funcstack[1] == _rg ]] || (( ! $+functions[compdef] )); then
|
||||
_rg "$@"
|
||||
else
|
||||
compdef _rg rg
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# ZSH COMPLETION REFERENCE
|
||||
|
Reference in New Issue
Block a user