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.
141
141
value, causes this script to perform a fuzzy search by words, matching in
142
142
given order e.g. ` ab c ` will match ` *ab*c* `
143
143
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`.
149
149
150
150
* ` HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ` is a global variable that defines
151
151
whether all search results returned are _ unique_ . If set to a non-empty
Original file line number Diff line number Diff line change 48
48
: ${HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS=' i' }
49
49
: ${HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=' ' }
50
50
: ${HISTORY_SUBSTRING_SEARCH_FUZZY=' ' }
51
- : ${HISTORY_SUBSTRING_SEARCH_PREFIX =' ' }
51
+ : ${HISTORY_SUBSTRING_SEARCH_PREFIXED =' ' }
52
52
53
53
# -----------------------------------------------------------------------------
54
54
# declare internal global variables
@@ -248,7 +248,13 @@ _history-substring-search-begin() {
248
248
# `(j:CHAR:)` join array to string with CHAR as seperator
249
249
#
250
250
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
252
258
253
259
#
254
260
# Find all occurrences of the search pattern in the history file.
You can’t perform that action at this time.
0 commit comments