hsmw: New feature – jump of history entries (Ctrl-J)

This commit is contained in:
Sebastian Gniazdowski 2016-11-30 07:53:44 +01:00
parent a215847fae
commit cec22e3e15

View file

@ -230,6 +230,22 @@ _hsmw_backward_kill_word() {
_hsmw_simulate_widget _hsmw_simulate_widget
} }
_hsmw_jump_entry() {
local entry
if (( __hsmw_ctx )); then
integer final_hist_found_idx the_index
final_hist_found_idx=__hsmw_ctx_text_idx+__hsmw_ctx_which-1
the_index="${__hsmw_ctx_found[final_hist_found_idx]}"
the_index+=__hsmw_ctx_idx
entry="${history[$the_index]}"
else
entry="${__hsmw_hcw_found[__hsmw_hcw_index]}"
fi
print -S "$entry"
}
if [[ "$__hsmw_hcw_call_count" -eq "1" ]]; then if [[ "$__hsmw_hcw_call_count" -eq "1" ]]; then
# Make the hsmw keymap a copy of the current main # Make the hsmw keymap a copy of the current main
bindkey -N hsmw emacs bindkey -N hsmw emacs
@ -304,6 +320,10 @@ if [[ "$__hsmw_hcw_call_count" -eq "1" ]]; then
# Removal of default Ctrl-R binding # Removal of default Ctrl-R binding
bindkey -M hsmw '^R' "$down_widget" bindkey -M hsmw '^R' "$down_widget"
# Jump binding
zle -N -- _hsmw_jump_entry
bindkey -M hsmw '^J' _hsmw_jump_entry
# Substitute self-insert, backward-delete-char, delete-char # Substitute self-insert, backward-delete-char, delete-char
zle -A self-insert hsmw-saved-self-insert zle -A self-insert hsmw-saved-self-insert
zle -A backward-delete-char hsmw-saved-backward-delete-char zle -A backward-delete-char hsmw-saved-backward-delete-char