From 9dc9cdcc87280d52faab06c152c6e35053efaf2e Mon Sep 17 00:00:00 2001 From: Roeniss Moon Date: Mon, 24 Mar 2025 00:16:03 +0900 Subject: [PATCH] fix(alias-finder): Handle the case where the command length is 1 or less --- plugins/alias-finder/alias-finder.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/alias-finder/alias-finder.plugin.zsh b/plugins/alias-finder/alias-finder.plugin.zsh index 5fdfbc835..4786431f3 100644 --- a/plugins/alias-finder/alias-finder.plugin.zsh +++ b/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"