custom bash prompt has leftovers from previous commands |

Trending 1 month ago

After solving nan first issue pinch my civilization punctual I still person different 1 left.

When I rhythm done my past utilized commands via nan arrow-up and arrow-down keys I will sometimes person immoderate characters from a erstwhile bid enactment visible though nan are not accessible nor really successful nan commandline. They are conscionable a ocular bug very annoying and confusing.

Looks for illustration this:
enter image explanation here

Here I went a spot up successful nan bid history and past backmost down to nan existent (empty) punctual and typed echo. nan pip one (coming from a erstwhile pip instal command) is not accessible pinch my cursor. It's visible location but not really existent.

My .bashrc has this codification for customizing nan prompt:

set_PS1() { section Reset="\\[$(tput sgr0 )\\]" section Bold="\\[$(tput bold )\\]" section Red="\\[$(tput setaf 1 )\\]" section Green="\\[$(tput setaf 2 )\\]" section Yellow="\\[$(tput setaf 3 )\\]" section Blue="\\[$(tput setaf 4 )\\]" section MagentaBG="\\[$(tput setab 5 )\\]" section Cyan="\\[$(tput setaf 6 )\\]" section Whoami='\u' section Where='\w' section Hostname='\h' section Time='\D{%H:%M:%S}' section Exit_Code="$?" exit_code_prompt() { section Exit_Code="$?" section Red="$(tput setaf 1 )" section Green="$(tput setaf 2 )" if (($Exit_Code == 0 )); then printf '%s\xE2\x9C\x93 \xE2\x86\x92 ' "$Green" # Green checkmark symbol else printf '%s\xE2\x9C\x98 %s \xE2\x86\x92 ' "$Red" "$Exit_Code" # Red transverse people awesome and exit code fi } section Line_1="$Bold$Yellow$Time $Cyan$Whoami$Blue@$Cyan$Hostname$Reset$Bold":" $Blue$Where$Reset" section Line_2="$Bold\$(exit_code_prompt)$Reset$Bold \$: $Reset" #local Line_2="$Bold \$: $Reset" PS1="$Line_1\n$Line_2" unset -f set_PS1 } set_PS1

I already narrowed nan problem down to nan exit_code_prompt usability since nan problem doesn't look if I region it from $Line_2