diff options
Diffstat (limited to 'plugins/alias-finder/alias-finder.plugin.zsh')
| -rw-r--r-- | plugins/alias-finder/alias-finder.plugin.zsh | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/plugins/alias-finder/alias-finder.plugin.zsh b/plugins/alias-finder/alias-finder.plugin.zsh index 5fdfbc835..6f24c7089 100644 --- a/plugins/alias-finder/alias-finder.plugin.zsh +++ b/plugins/alias-finder/alias-finder.plugin.zsh @@ -36,14 +36,22 @@ alias-finder() { # make filter to find only shorter results than current cmd if [[ $cheaper == true ]]; then cmdLen=$(echo -n "$cmd" | wc -c) - filter="^'{0,1}.{0,$((cmdLen - 1))}=" + if [[ $cmdLen -le 1 ]]; then + return + fi + + filter="^'?.{1,$((cmdLen - 1))}'?=" # some aliases is surrounded by single quotes fi - alias | grep -E "$filter" | grep -E "=$finder" + if (( $+commands[rg] )); then + alias | rg "$filter" | rg "=$finder" + else + alias | grep -E "$filter" | grep -E "=$finder" + fi if [[ $exact == true ]]; then break # because exact case is only one - elif [[ $longer = true ]]; then + elif [[ $longer == true ]]; then break # because above grep command already found every longer aliases during first cycle fi |
