2

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?

Sergey Grinev
  • 34,078
  • 10
  • 128
  • 141

1 Answers1

11

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.

Lev Levitsky
  • 63,701
  • 20
  • 147
  • 175