2

I recently updated my Ubuntu 14.04 using the software update.

This caused some problems. Initially I couldn't open up a new terminal window due to unknown errors with my .bashrc I had to use another shell to remove my .bashrc file to fix it. While slowly adding back the .bashrc file I now have a problem with my PS1 prompt settings.

For a while I've used

git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; }
HOST='\033[02;36m\]\h'; HOST=' '$HOST
TIME='\033[01;31m\]\t \033[01;32m\]'
LOCATION=' \033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,\}\)/\{0,1\}#\1_\2#g"`'
BRANCH=' \033[00;33m\]$(git_branch)\[\033[00m\]\n\$ '
PS1=$TIME$USER$HOST$LOCATION$BRANCH
PS2='\[\033[01;36m\]>'

in my .bashrc to show time, user, host, pwd and git branch (in various colors) within my prompt.

After the upgrade I have a strange character at the start of each of those that didn't used to be there. Some sort of small outlined box with 4 tiny numbers in it !

enter image description here

What is causing this & how to fix it?

1
  • With that "tiny box with 4 numbers", the terminal is showing you some character it cannot print in the current locale/characterset.
    – Ariel
    Commented Feb 28, 2015 at 13:22

1 Answer 1

3

The answer seems to be that I needed to add a \[ before the \033[ constructs, e.g.

Before:

HOST='\033[02;36m\]\h'; HOST=' '$HOST

After:

HOST='\[\033[02;36m\]\h'; HOST=' '$HOST

enter image description here

You must log in to answer this question.

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