From cfd129d94e03f178dda8d10eea3b2fb3b158a8e4 Mon Sep 17 00:00:00 2001 From: Scott Carroll Date: Sat, 13 Dec 2025 21:16:47 +0000 Subject: [PATCH] Fix fzf history for Ubuntu 22.04 --- bashprofile/.bash-profile.d/fzf-key-bindings.bash | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bashprofile/.bash-profile.d/fzf-key-bindings.bash b/bashprofile/.bash-profile.d/fzf-key-bindings.bash index c4dce3b..bd8bba0 100644 --- a/bashprofile/.bash-profile.d/fzf-key-bindings.bash +++ b/bashprofile/.bash-profile.d/fzf-key-bindings.bash @@ -49,10 +49,19 @@ __fzf_cd__() { dir=$(set +o pipefail; eval "$cmd" | FZF_DEFAULT_OPTS="$opts" $(__fzfcmd)) && printf 'builtin cd -- %q' "$dir" } +# scottc hack - make 22.04 fzf work +if fzf --help | grep "\-\-scheme" +then + SCHEME='--scheme=history' +else + SCHEME='' +fi +# end scottc hack + if command -v perl > /dev/null; then __fzf_history__() { local output opts script - opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind=ctrl-r:toggle-sort ${FZF_CTRL_R_OPTS-} +m --read0" + opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} -n2..,.. $SCHEME --bind=ctrl-r:toggle-sort ${FZF_CTRL_R_OPTS-} +m --read0" script='BEGIN { getc; $/ = "\n\t"; $HISTCOUNT = $ENV{last_hist} + 1 } s/^[ *]//; print $HISTCOUNT - $. . "\t$_" if !$seen{$_}++' output=$( set +o pipefail @@ -76,7 +85,7 @@ else # awk - fallback for POSIX systems IFS=' .' read n x y z d <<< $(command mawk -W version 2> /dev/null) [[ $n == mawk ]] && (( d >= 20230302 && (x *1000 +y) *1000 +z >= 1003004 )) && __fzf_awk=mawk fi - opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind=ctrl-r:toggle-sort ${FZF_CTRL_R_OPTS-} +m --read0" + opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} -n2..,.. $SCHEME --bind=ctrl-r:toggle-sort ${FZF_CTRL_R_OPTS-} +m --read0" [[ $(HISTTIMEFORMAT='' builtin history 1) =~ [[:digit:]]+ ]] # how many history entries script='function P(b) { ++n; sub(/^[ *]/, "", b); if (!seen[b]++) { printf "%d\t%s%c", '$((BASH_REMATCH + 1))' - n, b, 0 } } NR==1 { b = substr($0, 2); next }