mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
feat(alias-finder): use ripgrep if possible (#13043)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
This commit is contained in:
parent
e3e468d138
commit
537807c863
2 changed files with 10 additions and 4 deletions
|
|
@ -11,6 +11,8 @@ plugins=(... alias-finder)
|
||||||
|
|
||||||
To enable it for every single command, set zstyle in your `~/.zshrc`.
|
To enable it for every single command, set zstyle in your `~/.zshrc`.
|
||||||
|
|
||||||
|
If the user has installed `rg`([ripgrep](https://github.com/BurntSushi/ripgrep)), it will be used because it's faster. Otherwise, it will use the `grep` command.
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
# ~/.zshrc
|
# ~/.zshrc
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,11 @@ alias-finder() {
|
||||||
filter="^'?.{1,$((cmdLen - 1))}'?=" # some aliases is surrounded by single quotes
|
filter="^'?.{1,$((cmdLen - 1))}'?=" # some aliases is surrounded by single quotes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if (( $+commands[rg] )); then
|
||||||
|
alias | rg "$filter" | rg "=$finder"
|
||||||
|
else
|
||||||
alias | grep -E "$filter" | grep -E "=$finder"
|
alias | grep -E "$filter" | grep -E "=$finder"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $exact == true ]]; then
|
if [[ $exact == true ]]; then
|
||||||
break # because exact case is only one
|
break # because exact case is only one
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue