mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-19 02:02:32 +01:00
feat(alias-finder): Use ripgrep if possible
- basic grep is too slow for very long command. ripgrep can easily remediate this issue.
This commit is contained in:
parent
f81259fb34
commit
25b2c9f37e
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
|
||||||
|
|
||||||
alias | grep -E "$filter" | grep -E "=$finder"
|
if command -v rg >/dev/null 2>&1; then
|
||||||
|
alias | rg "$filter" | rg "=$finder"
|
||||||
|
else
|
||||||
|
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