Skip to content

Commit

Permalink
fuzzy matching takes into account uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
yazgoo committed Feb 24, 2024
1 parent b060683 commit 178c8f7
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions fsh
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,44 @@ fsh() {
running=false
}

filter_append_fuzzy() {
if [ "$terminal" = zsh ]
then
lower="${1:l}"
upper="${1:u}"
else
lower="${1,,}"
upper="${1^^}"
fi
[ "$1" = "$upper" ] && lower="$upper"
fuzzy_filter="${fuzzy_filter}.*[$lower$upper]"
}

filter_append() {
filter="${filter}${1}"
if [ -n "$no_fuzzy" ]
then
fuzzy_filter="${filter}"
else
if [ "$terminal" = zsh ]
then
fuzzy_filter="${fuzzy_filter}.*[${1:l}${1:u}]"
else
fuzzy_filter="${fuzzy_filter}.*[${1,,}${1^^}]"
fi
filter_append_fuzzy "$1"
fi
generate_choices_nums
}

filter_pop_fuzzy() {
for _ in {1..6}
do
fuzzy_filter="${fuzzy_filter%?}"
done
}

filter_pop() {
filter="${filter%?}"
if [ -n "$no_fuzzy" ]
then
fuzzy_filter="${filter}"
else
for _ in {1..6}
do
fuzzy_filter="${fuzzy_filter%?}"
done
filter_pop_fuzzy
fi
generate_choices_nums
}
Expand Down

0 comments on commit 178c8f7

Please sign in to comment.