1

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

2

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 :

\[\e[30;47m\]$(parse_git_branch)\W\[\e[30;47m\]$\[\e[0m\]

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\]

https://stackoverflow.com/q/5947742/28938235#28938235

https://stackoverflow.com/q/17432993/

https://stackoverflow.com/q/20697195/20698168#20698168

You must log in to answer this question.

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