fix(alias-finder): early return on cmd len <2 (#13030)

master
Roeniss Moon 12 months ago committed by GitHub
parent eeaf9f89b0
commit 1de190e439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      plugins/alias-finder/alias-finder.plugin.zsh

@ -36,7 +36,11 @@ 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"

Loading…
Cancel
Save