6

user prompt:

user - / :

up/down keys to locate historical commands.

user - / : historical command

clear the "historical command" :

user - / :hist

No matter how many times I hit BackSpace.. unable to delete "hist" part.

technically it is not even there. but on the screen it simply wont clear out until I hit "enter"

user - / :hist
user - / :

what causes it ?

The problem is probably due to the colors I used here. but how can It be corrected ?

PS1="\[\033[38;5;190m\]\u - \W : \e[m"
VIE
  • 195
  • Please note that the version of my answer you accepted had a mistake. You might want to see the updated one. – terdon Mar 03 '17 at 16:12
  • @terdon, I tried both the second one worked okay. that is why the answer was considered valid. – VIE Mar 03 '17 at 18:13

1 Answers1

8

Your final ANSII escape sequence isn't finished. The reset code (\e[0m), like the others, needs a [. Change your PS1 to:

PS1="\[\033[38;5;190m\]\u - \W : \[\e[0m"

Or, to keep things consistent:

PS1="\[\033[38;5;190m\]\u - \W : \[\033[0m"
terdon
  • 242,166
  • 1
    Just to be clear, m alone works fine, the problem was that it wasn't enclosed in \[\]. Your added \[ is what actually fixed the problem. – Random832 Mar 03 '17 at 14:20
  • @Random832 my understanding of the ANSII escape format is extremely limited, so thanks for pointing that out. In fact, my first version is still wrong (it's just that the problem is intermitent) since I hadn't actually added a \[. Fixed now (I hope), thanks. – terdon Mar 03 '17 at 16:11