Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements to bash init script #445

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/shell/atuin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,28 @@ ATUIN_SESSION=$(atuin uuid)
export ATUIN_SESSION

_atuin_preexec() {
local id; id=$(atuin history start "$1")
export ATUIN_HISTORY_ID="$id"
local id; 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
(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)"
HISTORY="$(RUST_LOG=error atuin search -i "${READLINE_LINE}" 3>&1 1>&2 2>&3)"
tput smkx

READLINE_LINE=${HISTORY}
READLINE_POINT=${#READLINE_LINE}
}


if [[ -n "${BLE_VERSION-}" ]]; then
blehook PRECMD-+=_atuin_precmd
blehook PREEXEC-+=_atuin_preexec
Expand All @@ -34,6 +32,8 @@ else
preexec_functions+=(_atuin_preexec)
fi

if [[ -z $ATUIN_NOBIND ]]; then
if [[ -z ${ATUIN_NOBIND} ]]; then
bind -x '"\C-r": __atuin_history'
bind -x '"\e[A": __atuin_history'
bind -x '"\eOA": __atuin_history'
fi