diff --git a/history-substring-search.zsh b/history-substring-search.zsh index 1239529..bbeb43d 100644 --- a/history-substring-search.zsh +++ b/history-substring-search.zsh @@ -49,6 +49,7 @@ zmodload -F zsh/parameter HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' +HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' # see "Globbing Flags" in zshexpn(1) history-substring-search-begin() { # continue using the previous "$history_substring_search_result" by default, @@ -66,7 +67,7 @@ history-substring-search-begin() { # find all occurrences of the pattern *${query}* within the history file # (k) turns it an array of line numbers. (on) seems to remove duplicates. # (on) are default options. they can be turned off by (ON). - history_substring_search_matches=(${(kon)history[(R)(#i)*${history_substring_search_query_escaped}*]}) + history_substring_search_matches=(${(kon)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${history_substring_search_query_escaped}*]}) # define the range of value that $history_substring_search_match_number # can take: [0, $history_substring_search_number_of_matches_plus_one] @@ -95,7 +96,7 @@ history-substring-search-highlight() { # among other things, the following expression yields a variable $MEND, # which indicates the end position of the first occurrence of # $history_substring_search_query_escaped in $BUFFER - : ${(S)BUFFER##(#mi)($history_substring_search_query##)} + : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($history_substring_search_query##)} let "history_substring_search_query_mbegin = $MEND - $#history_substring_search_query" # this is slightly more informative than highlighting that fish performs region_highlight+=("$history_substring_search_query_mbegin $MEND $1")