From d33f176595d8f9b0f820c7b663d27700917247ae Mon Sep 17 00:00:00 2001 From: scbj Date: Mon, 27 Jan 2025 13:45:57 +0100 Subject: [PATCH] usuable fzf-script --- scripts/fzf-bash-history | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/fzf-bash-history b/scripts/fzf-bash-history index 9f0ecae..7f1a3b6 100644 --- a/scripts/fzf-bash-history +++ b/scripts/fzf-bash-history @@ -1,3 +1,18 @@ -alias search-history='eval $(fc -lnr 1 | fzf --tmux )' +function __search-history { + current_line="${READLINE_LINE}" + if [[ -n $current_line ]]; then + command=$(fc -lnr 1 | fzf --scheme=history --tmux -q ${current_line}) + else + command=$(fc -lnr 1 | fzf --scheme=history --tmux) + fi + command=$(echo $command | xargs) + READLINE_LINE="${command}" + READLINE_POINT=$(( 0 + ${#command} )) +} + +if command -v fzf 2>&1 >/dev/null; then + bind -r "\C-r" + bind -x '"\C-r": __search-history' +fi