From cebda88f7b2a2263e0e304205eb5d570d5ddf122 Mon Sep 17 00:00:00 2001 From: crater2150 Date: Mon, 6 Mar 2017 17:15:09 +0100 Subject: [PATCH] Add accept-or-recall-and-infer-history Pressing Alt-Enter now uses accept-and-infer-history, with the addition of using the last executed command for inferring if pressed while the command line is empty --- modules/bindings/init | 15 +++++++++++++++ zshrc | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/bindings/init b/modules/bindings/init index 480b7e5..cdeb385 100644 --- a/modules/bindings/init +++ b/modules/bindings/init @@ -62,4 +62,19 @@ zle -N zle-line-finish insert_sudo () { zle beginning-of-line; zle -U "sudo " } zle -N insert-sudo insert_sudo + bindkey "^[s" insert-sudo + +local function accept-or-recall-and-infer-history() { + if [[ -z $PREBUFFER$BUFFER ]]; then + zle up-line-or-history + zle infer-next-history + + else + zle accept-and-infer-next-history -- "$@" + fi +} +zle -N accept-or-recall-and-infer-history + + +bindkey "\e^M" accept-or-recall-and-infer-history diff --git a/zshrc b/zshrc index 9cccfa5..7769757 100644 --- a/zshrc +++ b/zshrc @@ -2,10 +2,13 @@ HISTFILE=~/.histfile HISTSIZE=100000 SAVEHIST=100000 +unsetopt histsavenodups + setopt autocd extendedglob notify correct autonamedirs setopt list_ambiguous autopushd pushd_ignore_dups -setopt hist_ignore_all_dups hist_ignore_space share_history +setopt hist_ignore_space share_history +#setopt hist_ignore_all_dups setopt no_auto_remove_slash auto_param_slash setopt completeinword setopt chase_links