If you see the bell on the title, it means when I deleting string it was reaching $ sign and give a bell warns. But the strange thing is my cursor is not completely clear the string, it is still leaving my URL left over there. I already checked PS1 on my bash profile and it looks like this

export PS1='\e[1;32m\W \t \e[1;31m\u \e[1;32m$ \e[0m'

But when I resize the window of the terminal, suddenly it turns back normal.

copy paste


You need to enclose the non-printable characters properly in \[...\] block. This ensures that correct number of characters are counted while generating the prompt.

I had the same problem and here's the PS1 that gave no issues so far :


That is my understanding of what I read on SO:

You should add \[ before any starting ANSI code and add \] after any ending ones. Example: in regular usage: \033[32mThis is in green\033[0m for PS0/1/2/4: \[\033[32m\]This is in green\[\033[m\]

\[ is for start of a sequence of non-printable characters \] is for end of a sequence of non-printable characters

Tip: for memorize it you can first add \[\] and then put your ANSI code between them:
- \[start-ANSI-code\]
- \[end-ANSI-code\]




You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .