From 7b5c3d543d198a18884c990d540f5debc8a4d8d5 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Mon, 26 Apr 2021 11:50:31 +0100 Subject: Support bash, resolves #3 --- src/shell/atuin.bash | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/shell/atuin.bash (limited to 'src/shell/atuin.bash') diff --git a/src/shell/atuin.bash b/src/shell/atuin.bash new file mode 100644 index 00000000..43de3640 --- /dev/null +++ b/src/shell/atuin.bash @@ -0,0 +1,30 @@ +_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) + +bind -x '"\C-r": __atuin_history' -- cgit v1.3.1