From 07f363ba3ad225532a6020f33bfe414cafb7face Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Sat, 17 Feb 2024 10:50:19 +0000 Subject: Revert "Revert "fix(bash): avoid unexpected `atuin history start` for keybind…" (#1728) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 032ca19c73be45c39a2d7a9972cb7d47d34d31ce. --- atuin/src/shell/atuin.bash | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/atuin/src/shell/atuin.bash b/atuin/src/shell/atuin.bash index 4cd19b7e..e40e8c56 100644 --- a/atuin/src/shell/atuin.bash +++ b/atuin/src/shell/atuin.bash @@ -17,6 +17,14 @@ export ATUIN_SESSION ATUIN_HISTORY_ID="" __atuin_preexec() { + if [[ ! ${BLE_ATTACHED-} ]]; then + # With bash-preexec, preexec may be called even for the command run by + # keybindings. There is no general and robust way to detect the + # command for keybindings, but at least we want to exclude Atuin's + # keybindings. + [[ $BASH_COMMAND == '__atuin_history'* && $BASH_COMMAND != "$1" ]] && return 0 + fi + local id id=$(atuin history start -- "$1") export ATUIN_HISTORY_ID=$id -- cgit v1.3.1