From b105fa14a59893c416db5d961a2d93472b6e6601 Mon Sep 17 00:00:00 2001 From: quak Date: Tue, 28 Jan 2025 23:31:46 +0100 Subject: [PATCH] prepared fzf script for tab/enter (edit/execute) --- scripts/fzf-bash-history | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/fzf-bash-history b/scripts/fzf-bash-history index 7f1a3b6..7421845 100644 --- a/scripts/fzf-bash-history +++ b/scripts/fzf-bash-history @@ -2,13 +2,24 @@ function __search-history { current_line="${READLINE_LINE}" if [[ -n $current_line ]]; then - command=$(fc -lnr 1 | fzf --scheme=history --tmux -q ${current_line}) + command=($(fc -lnr 1 | fzf --scheme=history --tmux --expect=tab,right -q ${current_line})) else - command=$(fc -lnr 1 | fzf --scheme=history --tmux) + command=($(fc -lnr 1 | fzf --scheme=history --tmux --expect=tab,right)) fi - command=$(echo $command | xargs) + + # print command to terminal for editting + if [[ ${command[0]} = "tab" || ${command[0]} = "right" ]]; then + edit="true" + command=(${command[@]:1:${#command[@]}}) + fi + + # strip white space + command="${command[@]}" READLINE_LINE="${command}" READLINE_POINT=$(( 0 + ${#command} )) + if [[ -z ${edit} ]]; then + echo + fi } if command -v fzf 2>&1 >/dev/null; then