From 9c210e8987724c7278f8ee7b1505624611d79181 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 4 Feb 2024 02:43:56 +0900 Subject: fix(bash/preexec): erase the previous prompt before overwriting When the previous prompt is longer than the prompt calculated by the current PS1, some extra characters from the previous prompt remains in the terminal display. In this patch, we erase the content of the previous prompt before outputting our new prompt. --- atuin/src/shell/atuin.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/atuin/src/shell/atuin.bash b/atuin/src/shell/atuin.bash index 5b6a8dec..c632cf9d 100644 --- a/atuin/src/shell/atuin.bash +++ b/atuin/src/shell/atuin.bash @@ -106,10 +106,16 @@ __atuin_accept_line() { # Reprint the prompt, accounting for multiple lines local __atuin_prompt __atuin_prompt_offset __atuin_evaluate_prompt + local __atuin_clear_prompt + __atuin_clear_prompt=$'\r'$(tput el) if ((__atuin_prompt_offset > 0)); then - tput cuu "$__atuin_prompt_offset" + __atuin_clear_prompt+=$( + tput cuu "$__atuin_prompt_offset" + tput dl "$__atuin_prompt_offset" + tput il "$__atuin_prompt_offset" + ) fi - printf '%s\n' "$__atuin_prompt$__atuin_command" + printf '%s\n' "$__atuin_clear_prompt$__atuin_prompt$__atuin_command" # Add it to the bash history history -s "$__atuin_command" -- cgit v1.3.1