File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -141,11 +141,11 @@ default values.
141141 value, causes this script to perform a fuzzy search by words, matching in
142142 given order e.g. ` ab c ` will match ` *ab*c* `
143143
144- * ` HISTORY_SUBSTRING_SEARCH_PREFIX ` is a global variable that defines
145- how the command history will be searched for your query. If set to a non-empty
146- value, only history prefixed by your query will be matched. For example,
147- if this variable is empty, ` ls ` will match ` ls -l ` and ` echo ls ` ; if it is
148- non-empty, ` ls ` will only match ` ls -l ` .
144+ * ` HISTORY_SUBSTRING_SEARCH_PREFIXED ` is a global variable that defines how
145+ the command history will be searched for your query. If set to a non-empty
146+ value, your query will be matched against the start of each history entry.
147+ For example, if this variable is empty, ` ls ` will match ` ls -l ` and `echo
148+ ls ` ; if it is non-empty, ` ls` will only match ` ls -l`.
149149
150150* ` HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ` is a global variable that defines
151151 whether all search results returned are _ unique_ . If set to a non-empty
Original file line number Diff line number Diff line change 4848: ${HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS=' i' }
4949: ${HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=' ' }
5050: ${HISTORY_SUBSTRING_SEARCH_FUZZY=' ' }
51- : ${HISTORY_SUBSTRING_SEARCH_PREFIX =' ' }
51+ : ${HISTORY_SUBSTRING_SEARCH_PREFIXED =' ' }
5252
5353# -----------------------------------------------------------------------------
5454# declare internal global variables
@@ -248,7 +248,13 @@ _history-substring-search-begin() {
248248 # `(j:CHAR:)` join array to string with CHAR as seperator
249249 #
250250 local search_pattern=" ${(j:*: )_history_substring_search_query_parts[@]// (# m)[\][()|\\*?#<>~^]/ \\ $MATCH } *"
251- test -z " $HISTORY_SUBSTRING_SEARCH_PREFIX " && search_pattern=" *$search_pattern "
251+
252+ #
253+ # Support anchoring history search to the beginning of the command
254+ #
255+ if [[ -z $HISTORY_SUBSTRING_SEARCH_PREFIXED ]]; then
256+ search_pattern=" *${search_pattern} "
257+ fi
252258
253259 #
254260 # Find all occurrences of the search pattern in the history file.
You can’t perform that action at this time.
0 commit comments