This commit is contained in:
Alexander Navarro 2023-02-21 18:22:19 -03:00
parent 4524a86376
commit 0552ffdae8
37 changed files with 8770 additions and 49 deletions

View file

@ -0,0 +1,25 @@
fzf-atuin-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
selected=( $(atuin history list --cmd-only | tac | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' | bat --color=always --wrap never --language=sh --style=plain |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} ${FZF_DEFAULT_OPTS-} --scheme=history --bind=ctrl-r:toggle-sort,ctrl-z:ignore ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
local ret=$?
if [ -n "$selected" ]; then
cmd=$selected[1,-1]
if [ -n "$cmd" ]; then
zle vi-fetch-history -n $cmd
fi
fi
zle -U "$cmd"
zle kill-buffer
zle reset-prompt
return $ret
}
if ! command -v atuin > /dev/null; then
zle -N fzf-history-widget
bindkey '^R' fzf-history-widget
else
zle -N fzf-atuin-history-widget
bindkey '^R' fzf-atuin-history-widget
fi