Question

I have next line in .bashrc:

PS1="\e[0;32m[ \w ]\n#\e[m "

to set very simple welcome line of green color. On Ubuntu using arrow up/down to load previous commands puts extra symbols to the command line:

[ /tmp ]
# echo "hello there"
hello there
[ /tmp ]
# echecho "hello there"

Notice ech symbols in front of last command. These symbols can't be edited -- cursor doesn't go there.

What I did wrong?

Was it helpful?

Solution

You need to escape the characters that are not displayed. Change the line in .bashrc to the following:

PS1="\[\e[0;32m\][ \w ]\n#\[\e[m\] "

Run source ~/.bashrc to apply the changes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top