From 7fbd3e390f59507f88a06680f58097287d892a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 21 Jan 2022 12:07:34 +0100 Subject: [PATCH 1/2] Fix intendation --- src/shell/atuin.bash | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/shell/atuin.bash b/src/shell/atuin.bash index 40bed30e7d7..c1b667b5f9c 100644 --- a/src/shell/atuin.bash +++ b/src/shell/atuin.bash @@ -2,25 +2,24 @@ ATUIN_SESSION=$(atuin uuid) export ATUIN_SESSION _atuin_preexec() { - id=$(atuin history start "$1") - export ATUIN_HISTORY_ID="$id" + id=$(atuin history start "$1") + export ATUIN_HISTORY_ID="$id" } _atuin_precmd() { - local EXIT="$?" + local EXIT="$?" - [[ -z "${ATUIN_HISTORY_ID}" ]] && return + [[ -z "${ATUIN_HISTORY_ID}" ]] && return - - (RUST_LOG=error atuin history end "$ATUIN_HISTORY_ID" --exit $EXIT &) > /dev/null 2>&1 + (RUST_LOG=error atuin history end "$ATUIN_HISTORY_ID" --exit $EXIT &) > /dev/null 2>&1 } __atuin_history () { - tput rmkx + tput rmkx HISTORY="$(RUST_LOG=error atuin search -i "$BUFFER" 3>&1 1>&2 2>&3)" - tput smkx + tput smkx READLINE_LINE=${HISTORY} READLINE_POINT=${#READLINE_LINE} @@ -31,5 +30,5 @@ preexec_functions+=(_atuin_preexec) precmd_functions+=(_atuin_precmd) if [[ -z $ATUIN_NOBIND ]]; then - bind -x '"\C-r": __atuin_history' + bind -x '"\C-r": __atuin_history' fi From a9732c3fbc3cd03f8cdaf7ca84f211196a21da96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 21 Jan 2022 12:07:46 +0100 Subject: [PATCH 2/2] Add support for blesh See https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A71-Introduction#user-content-fn-blehook for more details --- src/shell/atuin.bash | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/shell/atuin.bash b/src/shell/atuin.bash index c1b667b5f9c..8f2c86f2132 100644 --- a/src/shell/atuin.bash +++ b/src/shell/atuin.bash @@ -26,8 +26,13 @@ __atuin_history () } -preexec_functions+=(_atuin_preexec) -precmd_functions+=(_atuin_precmd) +if [[ -v BLE_VERSION ]]; then + blehook PRECMD+=_atuin_precmd + blehook PREEXEC+=_atuin_preexec +else + precmd_functions+=(_atuin_precmd) + preexec_functions+=(_atuin_preexec) +fi if [[ -z $ATUIN_NOBIND ]]; then bind -x '"\C-r": __atuin_history'