From a52568be795b891c96438ec116ce0b29723655e7 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Tue, 5 Dec 2023 09:56:47 -0800 Subject: fix: reenable enter_accept for bash (#1408) * fix: reenable enter_accept for bash * fix: Fix the shellcheck warnings --- atuin/src/command/client/search/interactive.rs | 2 +- atuin/src/shell/atuin.bash | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs index 167eb23a..3373d51b 100644 --- a/atuin/src/command/client/search/interactive.rs +++ b/atuin/src/command/client/search/interactive.rs @@ -705,7 +705,7 @@ pub async fn history( if index < results.len() { let mut command = results.swap_remove(index).command; - if accept && (utils::is_zsh() || utils::is_fish()) { + if accept && (utils::is_zsh() || utils::is_fish() || utils::is_bash()) { command = String::from("__atuin_accept__:") + &command; } diff --git a/atuin/src/shell/atuin.bash b/atuin/src/shell/atuin.bash index 3da296bb..bd9506e5 100644 --- a/atuin/src/shell/atuin.bash +++ b/atuin/src/shell/atuin.bash @@ -1,4 +1,5 @@ ATUIN_SESSION=$(atuin uuid) +ATUIN_STTY=$(stty -g) export ATUIN_SESSION __atuin_preexec() { @@ -53,8 +54,16 @@ __atuin_history() { # shellcheck disable=SC2154 __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command" fi + # Juggle the terminal settings so that the command can be interacted with + local stty_backup + stty_backup=$(stty -g) + stty "$ATUIN_STTY" + eval "$HISTORY" exit_status=$? + + stty "$stty_backup" + # Execute preprompt commands __atuin_set_ret_value "$exit_status" "$HISTORY" eval "$PROMPT_COMMAND" -- cgit v1.3.1