Pull history-search-end into my bashrc
This commit is contained in:
parent
fa989aa26b
commit
ae7936f490
1 changed files with 37 additions and 1 deletions
|
@ -143,13 +143,49 @@ then
|
|||
bind 'set bell-style none'
|
||||
bind 'set completion-ignore-case on'
|
||||
bind 'set enable-bracketed-paste off'
|
||||
elif [ -n "$ZSH_VERSION" ]
|
||||
fi
|
||||
|
||||
if [ -n "$ZSH_VERSION" ]
|
||||
then
|
||||
function history-search-end {
|
||||
#
|
||||
# This implements functions like history-beginning-search-{back,for}ward,
|
||||
# but takes the cursor to the end of the line after moving in the
|
||||
# history, like history-search-{back,for}ward. To use them:
|
||||
# zle -N history-beginning-search-backward-end history-search-end
|
||||
# zle -N history-beginning-search-forward-end history-search-end
|
||||
# bindkey '...' history-beginning-search-backward-end
|
||||
# bindkey '...' history-beginning-search-forward-end
|
||||
|
||||
integer cursor=$CURSOR mark=$MARK
|
||||
|
||||
if [[ $LASTWIDGET = history-beginning-search-*-end ]]; then
|
||||
# Last widget called set $MARK.
|
||||
CURSOR=$MARK
|
||||
else
|
||||
MARK=$CURSOR
|
||||
fi
|
||||
|
||||
if zle .${WIDGET%-end}; then
|
||||
# success, go to end of line
|
||||
zle .end-of-line
|
||||
else
|
||||
# failure, restore position
|
||||
CURSOR=$cursor
|
||||
MARK=$mark
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
zle -N history-beginning-search-backward-end history-search-end
|
||||
zle -N history-beginning-search-forward-end history-search-end
|
||||
bindkey -e
|
||||
bindkey "^[[1;5C" forward-word
|
||||
bindkey "^[[1;5D" backward-word
|
||||
bindkey "^[[A" history-beginning-search-backward-end
|
||||
bindkey "^[[B" history-beginning-search-forward-end
|
||||
bindkey "^[OA" history-beginning-search-backward-end
|
||||
bindkey "^[OB" history-beginning-search-forward-end
|
||||
fi
|
||||
|
||||
# Set the prompt for various shells. The prompt should look like "user@host$ "
|
||||
|
|
Loading…
Reference in a new issue