Ypsilon
Ypsilon

Reputation: 122

Bash prompt buggy when going through history

I have customised my PS1 bash variable, but when I go through the history it starts getting bugged and doing weird stuff. I've gone several times over it but can't seem to find anything wrong.

\[\e]0;\u@\h: \w\a\]\[\033[01;32m\]\u@\h\[\033[00m\]\[\e[31m\] (production)\[\e[0m:\]\[\033[01;34m\]\w\[\e[m\]$

The moment when, going through the history, starts to behave weirdly, seems to be somehow related with long lines that need wrapping...

Upvotes: 0

Views: 452

Answers (1)

wjandrea
wjandrea

Reputation: 32954

The problem is in \[\e[0m:\]. Colon : is a printing character, so it should be outside the nonprinting delimiters, i.e. \[\e[0m\]:.

In the future if you have problems with your PS1, try breaking it into chunks and testing each one.

Upvotes: 3

Related Questions