diff options
author | Ellie Huxtable <e@elm.sh> | 2021-04-26 11:50:31 +0100 |
---|---|---|
committer | Ellie Huxtable <e@elm.sh> | 2021-04-26 11:57:30 +0100 |
commit | 7b5c3d543d198a18884c990d540f5debc8a4d8d5 (patch) | |
tree | ffc6b9121f1b1299f1b30a26322e1988683c06c7 /src/shell | |
parent | 4f16e8411e24891b140690798c47747f5c9bb91e (diff) |
Support bash, resolves #3
Diffstat (limited to 'src/shell')
-rw-r--r-- | src/shell/atuin.bash | 30 | ||||
-rw-r--r-- | src/shell/atuin.zsh | 2 |
2 files changed, 31 insertions, 1 deletions
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' diff --git a/src/shell/atuin.zsh b/src/shell/atuin.zsh index cdef5e54..6a24de50 100644 --- a/src/shell/atuin.zsh +++ b/src/shell/atuin.zsh @@ -6,7 +6,7 @@ export ATUIN_HISTORY="atuin history list" export ATUIN_BINDKEYS="true" _atuin_preexec(){ - id=$(atuin history start $1) + id=$(atuin history start "$1") export ATUIN_HISTORY_ID="$id" } |