aboutsummaryrefslogtreecommitdiffstats
path: root/src/shell/atuin.bash
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@sap.com>2022-01-25 19:33:25 +0100
committerGitHub <noreply@github.com>2022-01-25 18:33:25 +0000
commit7651f89261993c9a51e70b7225894a20442486f7 (patch)
treee2a0f4a8b04dce49acfe3ba2f6a29b9d00dcaab0 /src/shell/atuin.bash
parentfix: get install.sh working on UbuntuWSL (#260) (diff)
downloadatuin-7651f89261993c9a51e70b7225894a20442486f7.zip
Add support for blesh (#267)
* Fix intendation * Add support for blesh See https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A71-Introduction#user-content-fn-blehook for more details
Diffstat (limited to 'src/shell/atuin.bash')
-rw-r--r--src/shell/atuin.bash26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/shell/atuin.bash b/src/shell/atuin.bash
index 40bed30e..8f2c86f2 100644
--- a/src/shell/atuin.bash
+++ b/src/shell/atuin.bash
@@ -2,34 +2,38 @@ 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}
}
-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'
+ bind -x '"\C-r": __atuin_history'
fi