So my bash prompt looks like this [parth:~]$ and if I go cd to Desktop, it looks like this [parth:Desktop]$. I only want to see the current directory, next to my username so if I go to a folder, in Desktop, it would replace Desktop with the current directory name.

This is what I have in my ~/.bash_profile to make it look like this: export PS1='[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]]\$ '

This PS1 also follows the color highlighting of my terminal theme.

The problem is that when I click the up arrow key a few times (for the previous commands) and then click the down arrow key, the prompt gets messed up. It appends a part of the previous command to my prompt and I have to enter CTRL + C to reset it. Also when my command reaches the end of the line, instead of going to the new line, it wraps around the same line.

How do I fix this?


As far as I have been able to tell, this is caused by a bug in iTerm2, where actions such as ctrl+a make it act as though the colour-specifying characters in PS1 are treated as though they have a length.

The best solution I have found is to not specify colours in your .bashrc, and instead use triggers to generate the colours.

You must log in to answer this question.

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