mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-23 00:34:20 +01:00
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.
This commit is contained in:
parent
b00887562b
commit
9c210e8987
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user