reorganize configuration, functions, and details
This commit is contained in:
parent
ffaecb6efc
commit
f1ab1a7601
1 changed files with 58 additions and 46 deletions
|
|
@ -60,6 +60,48 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# configuration variables
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
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' # "i" means case insensitive, see "Globbing Flags" in zshexpn(1)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# the main ZLE widgets
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
history-substring-search-up() {
|
||||
_history-substring-search-begin
|
||||
|
||||
_history-substring-search-up-history ||
|
||||
_history-substring-search-up-buffer ||
|
||||
_history-substring-search-up-search
|
||||
|
||||
_history-substring-search-end
|
||||
}
|
||||
|
||||
history-substring-search-down() {
|
||||
_history-substring-search-begin
|
||||
|
||||
_history-substring-search-down-history ||
|
||||
_history-substring-search-down-buffer ||
|
||||
_history-substring-search-down-search
|
||||
|
||||
_history-substring-search-end
|
||||
}
|
||||
|
||||
zle -N history-substring-search-up
|
||||
zle -N history-substring-search-down
|
||||
|
||||
bindkey '\e[A' history-substring-search-up
|
||||
bindkey '\e[B' history-substring-search-down
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# implementation details
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
setopt extendedglob
|
||||
zmodload -F zsh/parameter
|
||||
|
||||
|
|
@ -168,10 +210,6 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
|
|||
#-------------->8------------------->8------------------->8-----------------
|
||||
fi
|
||||
|
||||
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' # "i" means case insensitive, see "Globbing Flags" in zshexpn(1)
|
||||
|
||||
_history-substring-search-begin() {
|
||||
_history_substring_search_move_cursor_eol=false
|
||||
|
||||
|
|
@ -219,6 +257,22 @@ _history-substring-search-begin() {
|
|||
fi
|
||||
}
|
||||
|
||||
_history-substring-search-end() {
|
||||
_history_substring_search_result=$BUFFER
|
||||
|
||||
if [[ $_history_substring_search_move_cursor_eol == true ]]; then
|
||||
# Move the cursor to the end of the $BUFFER.
|
||||
CURSOR=${#BUFFER}
|
||||
fi
|
||||
|
||||
# For debugging purposes:
|
||||
# zle -R "mn: "$_history_substring_search_match_number" m#: "${#_history_substring_search_matches}
|
||||
# read -k -t 200 && zle -U $REPLY
|
||||
|
||||
# Exit successfully from the history-substring-search-* widgets.
|
||||
true
|
||||
}
|
||||
|
||||
_history-substring-search-highlight() {
|
||||
_zsh_highlight
|
||||
|
||||
|
|
@ -486,47 +540,5 @@ _history-substring-search-down-search() {
|
|||
fi
|
||||
}
|
||||
|
||||
_history-substring-search-end() {
|
||||
_history_substring_search_result=$BUFFER
|
||||
|
||||
if [[ $_history_substring_search_move_cursor_eol == true ]]; then
|
||||
# Move the cursor to the end of the $BUFFER.
|
||||
CURSOR=${#BUFFER}
|
||||
fi
|
||||
|
||||
# For debugging purposes:
|
||||
# zle -R "mn: "$_history_substring_search_match_number" m#: "${#_history_substring_search_matches}
|
||||
# read -k -t 200 && zle -U $REPLY
|
||||
|
||||
# Exit successfully from the history-substring-search-* widgets.
|
||||
true
|
||||
}
|
||||
|
||||
history-substring-search-up() {
|
||||
_history-substring-search-begin
|
||||
|
||||
_history-substring-search-up-history ||
|
||||
_history-substring-search-up-buffer ||
|
||||
_history-substring-search-up-search
|
||||
|
||||
_history-substring-search-end
|
||||
}
|
||||
|
||||
history-substring-search-down() {
|
||||
_history-substring-search-begin
|
||||
|
||||
_history-substring-search-down-history ||
|
||||
_history-substring-search-down-buffer ||
|
||||
_history-substring-search-down-search
|
||||
|
||||
_history-substring-search-end
|
||||
}
|
||||
|
||||
zle -N history-substring-search-up
|
||||
zle -N history-substring-search-down
|
||||
|
||||
bindkey '\e[A' history-substring-search-up
|
||||
bindkey '\e[B' history-substring-search-down
|
||||
|
||||
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue