Skip to content

Commit

Permalink
Add support for blesh (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 authored Jan 25, 2022
1 parent c2dd332 commit 7651f89
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/shell/atuin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7651f89

Please sign in to comment.