diff options
| author | Koichi Murase <myoga.murase@gmail.com> | 2024-02-04 02:43:56 +0900 |
|---|---|---|
| committer | Ellie Huxtable <ellie@elliehuxtable.com> | 2024-02-03 23:49:14 +0100 |
| commit | 9c210e8987724c7278f8ee7b1505624611d79181 (patch) | |
| tree | 3ba160464eb0c22819146ec95b822d21a38594e1 | |
| parent | fix(bash/preexec): erase the prompt last line before Bash renders it (diff) | |
| download | atuin-9c210e8987724c7278f8ee7b1505624611d79181.zip | |
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.
| -rw-r--r-- | atuin/src/shell/atuin.bash | 10 |
1 files 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" |
