add HISTORY_SUBSTRING_SEARCH_PREFIX (#112,#115)
* `HISTORY_SUBSTRING_SEARCH_PREFIX` is a global variable that defines how the command history will be searched for your query. If set to a non-empty value, only history prefixed by your query will be matched. For example, if this variable is empty, `ls` will match `ls -l` and `echo ls`; if it is non-empty, `ls` will only match `ls -l`. Co-authored-by: Xue Qianming <qianmingxue@microsoft.com>
This commit is contained in:
parent
0f80b8eb33
commit
4f2f17cc46
2 changed files with 9 additions and 1 deletions
|
|
@ -48,6 +48,7 @@ typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
|
|||
typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
|
||||
typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=''
|
||||
typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY=''
|
||||
typeset -g HISTORY_SUBSTRING_SEARCH_PREFIX=''
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# declare internal global variables
|
||||
|
|
@ -246,7 +247,8 @@ _history-substring-search-begin() {
|
|||
# Escape and join query parts with wildcard character '*' as seperator
|
||||
# `(j:CHAR:)` join array to string with CHAR as seperator
|
||||
#
|
||||
local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
||||
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
||||
test -z "$HISTORY_SUBSTRING_SEARCH_PREFIX" && search_pattern="*$search_pattern"
|
||||
|
||||
#
|
||||
# Find all occurrences of the search pattern in the history file.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue