atuin/atuin.plugin.zsh

37 lines
622 B
Bash
Raw Normal View History

2020-10-05 02:00:55 +02:00
# Source this in your ~/.zshrc
2021-02-13 21:48:40 +01:00
export ATUIN_SESSION=$(atuin uuid)
export ATUIN_FUZZY=fzf
2020-10-05 02:00:55 +02:00
2021-02-13 13:58:40 +01:00
_atuin_preexec(){
2021-02-13 18:02:52 +01:00
id=$(atuin history start $1)
export ATUIN_HISTORY_ID="$id"
}
_atuin_precmd(){
local EXIT="$?"
[[ -z "${ATUIN_HISTORY_ID}" ]] && return
atuin history end $ATUIN_HISTORY_ID --exit $EXIT
2020-10-05 02:00:55 +02:00
}
_atuin_search(){
2021-02-13 23:24:23 +01:00
emulate -L zsh
zle -I
output=$(atuin history list --distinct | $ATUIN_FUZZY)
if [[ -n $output ]] ; then
LBUFFER=$output
fi
zle reset-prompt
}
2021-02-13 13:58:40 +01:00
add-zsh-hook preexec _atuin_preexec
2021-02-13 18:02:52 +01:00
add-zsh-hook precmd _atuin_precmd
zle -N _atuin_search_widget _atuin_search
bindkey '^r' _atuin_search_widget