Wednesday 3 January 2018

command line - PS1 problem, cmd is looping


I've set PS1 to the following value:


PS1="\033[0;37m[\033[1;33m\w\033[0;37m]\n\t \[[34m\]\u\033[0;37m@\[[34m\]\[[1m\]\h\[(B[m\] $"

The problem is that any command spanning more than a line loops around and don't generate a new line. So I overwrite the line that I already have typed. What is wrong with the PS1?



Answer



Non-printing characters in the prompt need to be surrounded by \[ and \] so that bash can properly track the length of the prompt and accommodate lines that go beyond the edge of the terminal.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...