3

I installed Ubuntu 11.10 mini + LXDE and wanted to make my command line different in terminal (than just plain white), so I added blue color to path line (everything until $ sign) and it works fine but I have two strange glitches now:

  1. When I write a line which is longer than terminal window, instead of starting at next line it starts at the same one, overwriting everything which was in there.
  2. Sometimes while navigating over previous commands (up/down arrow keys) some part of command gets stuck and is treated as part of prompt (the blue text), but it is white and is non-deletable and is not taken as part of command when I press enter.

What could I have messed up? The bad thing is that I don't remember what exactly I changed, but I'm sure I changed only one line in .bashrc

Edit: For anyone else who is interested in customizing the prompt, here's a nice tutorial . Make sure you don't miss any symbols (especially '' ones) and everything works fine.

3 Answers 3

4

I'm very late, but the problem here is that Bash doesn't know where to place the cursor, because it interprets the special colour code characters as normal text. This is fixed by putting \[ and \] tags around the colour codes. Instead of writing \e[1;31m to make text red, you should write \[\e[1;31m\].

If you're having this problem, carefully check all colour escape codes to see if they have those tags around them.

2

The default bashrc can be found in /etc/skel/.bashrc. I would suggest you make a backup of your current bashrc, then replace your bashrc with the one in skel, then see if the problems still occur. Then if they don't, backup and edit your new bashrc, putting comments in saying what you did!!

1
  • Thanks a lot. This was mine small mistake with all those symbols, i've missed some. Now thanks to /skel file and a guide at ArchWiki I managed to fix this. Thanks again
    – foxy
    Nov 21, 2011 at 10:19
0

I had the same symptoms, but in my case the problem was the ASCII bell escape sequence \a in my Bash prompt which leaded to the problem. The color codes were correctly enclosed by brackets (thanks @ringstaart).

My problematic Bash prompt setting in .bashrc was (omitting the color variable definitions):

PS1="\[$BLUE\]\u@\h: \[$YELLOW\]\w\a\\[$PURPLE\]\[$WHITE\]\$ "

Simply removing the \a solved the problem:

PS1="\[$BLUE\]\u@\h: \[$YELLOW\]\w\\[$PURPLE\]\[$WHITE\]\$ "

You must log in to answer this question.

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