diff options
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | atuin/src/shell/atuin.bash | 19 |
2 files changed, 23 insertions, 0 deletions
@@ -265,6 +265,8 @@ antigen bundle atuinsh/atuin@main ### bash +Atuin works in `bash >= 3.1`, but we recommend to use Atuin with the recent versions of `bash >= 5`. + #### [ble.sh](https://github.com/akinomyoga/ble.sh) Atuin works best in bash when using [ble.sh](https://github.com/akinomyoga/ble.sh) >= 0.4. @@ -298,6 +300,8 @@ echo 'eval "$(atuin init bash)"' >> ~/.bashrc bash-preexec currently has an issue where it will stop honoring `ignorespace`. While Atuin will ignore commands prefixed with whitespace, they may still end up in your bash history. Please check your configuration! All other shells do not have this issue. +To use Atuin in `bash < 4` with bash-preexec, the option `enter_accept` needs to be turned on (which is so by default). + ### fish Add diff --git a/atuin/src/shell/atuin.bash b/atuin/src/shell/atuin.bash index 3814193e..933416e6 100644 --- a/atuin/src/shell/atuin.bash +++ b/atuin/src/shell/atuin.bash @@ -1,3 +1,16 @@ +# Include guard +[[ ${__atuin_initialized-} == true ]] && return 0 +__atuin_initialized=true + +# Enable only in interactive shells +[[ $- == *i* ]] || return 0 + +# Require bash >= 3.1 +if ((BASH_VERSINFO[0] < 3 || BASH_VERSINFO[0] == 3 && BASH_VERSINFO[1] < 1)); then + [[ -t 2 ]] && printf 'atuin: requires bash >= 3.1 for the integration.\n' >&2 + return 0 +fi + ATUIN_SESSION=$(atuin uuid) ATUIN_STTY=$(stty -g) export ATUIN_SESSION @@ -154,6 +167,12 @@ __atuin_history() { fi fi + # READLINE_LINE and READLINE_POINT are only supported by bash >= 4.0 or + # ble.sh. When it is not supported, we localize them to suppress strange + # behaviors. + [[ ${BLE_ATTACHED-} ]] || ((BASH_VERSINFO[0] >= 4)) || + local READLINE_LINE="" READLINE_POINT=0 + local __atuin_output __atuin_output=$(ATUIN_SHELL_BASH=t ATUIN_LOG=error atuin search "$@" -i -- "$READLINE_LINE" 3>&1 1>&2 2>&3) |
