From 18261fe31cf1270f9aa783f99bbdbca343f89479 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 29 Mar 2020 21:26:52 +0900 Subject: [shell] Update CTRL-R to remove duplicate commands Close #1940 Related: #1363 #749 #270 #49 #88 #492 #600 --- shell/key-bindings.bash | 2 +- shell/key-bindings.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'shell') diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash index 71cd9991..16e1ec5b 100644 --- a/shell/key-bindings.bash +++ b/shell/key-bindings.bash @@ -55,7 +55,7 @@ __fzf_history__() { local output output=$( builtin fc -lnr -2147483648 | - last_hist=$(HISTTIMEFORMAT='' builtin history 1) perl -p -l0 -e 'BEGIN { getc; $/ = "\n\t"; $HISTCMD = $ENV{last_hist} + 1 } s/^[ *]//; $_ = $HISTCMD - $. . "\t$_"' | + last_hist=$(HISTTIMEFORMAT='' builtin history 1) perl -n -l0 -e 'BEGIN { getc; $/ = "\n\t"; $HISTCMD = $ENV{last_hist} + 1 } s/^[ *]//; print $HISTCMD - $. . "\t$_" if !$seen{$_}++' | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m --read0" $(__fzfcmd) --query "$READLINE_LINE" ) || return READLINE_LINE=${output#*$'\t'} diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh index e291677d..79b83880 100644 --- a/shell/key-bindings.zsh +++ b/shell/key-bindings.zsh @@ -68,7 +68,7 @@ bindkey '\ec' fzf-cd-widget fzf-history-widget() { local selected num setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null - selected=( $(fc -rl 1 | + selected=( $(fc -rl 1 | perl -ne 'print if !$seen{($_ =~ s/^\s*[0-9]+\s+//r)}++' | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) ) local ret=$? if [ -n "$selected" ]; then -- cgit v1.2.3