atuin/atuin.plugin.zsh

38 lines
638 B
Bash
Raw Normal View History

2020-10-04 18:00:55 -06:00
# Source this in your ~/.zshrc
2021-02-13 13:48:40 -07:00
export ATUIN_SESSION=$(atuin uuid)
export ATUIN_FUZZY=fzf
2020-10-04 18:00:55 -06:00
2021-02-13 05:58:40 -07:00
_atuin_preexec(){
2021-02-13 10:02:52 -07: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-04 18:00:55 -06:00
}
_atuin_search(){
2021-02-13 15:24:23 -07: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 05:58:40 -07:00
add-zsh-hook preexec _atuin_preexec
2021-02-13 10:02:52 -07:00
add-zsh-hook precmd _atuin_precmd
zle -N _atuin_search_widget _atuin_search
bindkey -r '^r'
bindkey '^r' _atuin_search_widget