if which atuin > /dev/null 2>&1 ; then ATUIN_SESSION=$(atuin uuid) export ATUIN_SESSION _atuin_preexec() { id=$(atuin history start "$1") export ATUIN_HISTORY_ID="$id" } _atuin_precmd() { local EXIT="$?" [[ -z "${ATUIN_HISTORY_ID}" ]] && return (RUST_LOG=error atuin history end "$ATUIN_HISTORY_ID" --exit $EXIT &) > /dev/null 2>&1 } __atuin_history () { tput rmkx HISTORY="$(RUST_LOG=error atuin search -i "$BUFFER" 3>&1 1>&2 2>&3)" tput smkx READLINE_LINE=${HISTORY} READLINE_POINT=${#READLINE_LINE} } preexec_functions+=(_atuin_preexec) precmd_functions+=(_atuin_precmd) if [[ -z $ATUIN_NOBIND ]]; then bind -x '"\C-r": __atuin_history' fi else # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth ## ## history: http://mywiki.wooledge.org/BashFAQ/088 ## # Big history HISTFILESIZE=10000 HISTSIZE=10000 HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S " # history -a causes an immediate write of all new history lines # (instead of upon shell exit) PROMPT_COMMAND="history -a" # histappend which causes all new history lines to be appended, and ensures # that multiple logins do not overwrite each other's history shopt -s histappend fi