Ubuntu – Custom bash prompt is buggy

bashcommand lineprompt

I followed some articles on how to change the prompt, I've got the result I was looking for, but when the cursor reach the end of the screen it doesn't go new line and tab completion it's strange.

# ~/.bashrc

# colorful, with time, history id and path (also in window title)
export PS1="\[\e]0;\w\a\]\e[1;36m\t-\! - \w>\e[m "

Anybody have got a clue on what am I doing wrong?

Best Answer

The colour setting escape sequences need to be enclosed in \[ and \] in order to tell bash readline that they don't contribute to the length of the line. This should do it:

PS1="\[\e]0;\w\a\e[1;36m\]\t-\! - \w>\[\e[m\] "