From cec22e3e15ecf750f5a7ecc865def0eb7ac78f00 Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski Date: Wed, 30 Nov 2016 07:53:44 +0100 Subject: [PATCH] =?UTF-8?q?hsmw:=20New=20feature=20=E2=80=93=20jump=20of?= =?UTF-8?q?=20history=20entries=20(Ctrl-J)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- history-search-multi-word | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/history-search-multi-word b/history-search-multi-word index 52981f2..8a46f73 100644 --- a/history-search-multi-word +++ b/history-search-multi-word @@ -230,6 +230,22 @@ _hsmw_backward_kill_word() { _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 # Make the hsmw keymap a copy of the current main bindkey -N hsmw emacs @@ -304,6 +320,10 @@ if [[ "$__hsmw_hcw_call_count" -eq "1" ]]; then # Removal of default Ctrl-R binding 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 zle -A self-insert hsmw-saved-self-insert zle -A backward-delete-char hsmw-saved-backward-delete-char