Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So when I type with my new bash prompt it goes on for a while, but if the command gets to long it loops around itself and writes over bash prompt. Here is my PS1 :

PS1='\e[0;34m\A\e[m | \e[0;31m-\e[m \e[0;32m>>\e[m  '

For reference, here are the lines from a standard .bashrc relevant to PS1:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
share|improve this question
For reference, here are the lines from a standard .bashrc relevant to PS1: My guess is that you don't have any closing brackets in your PS1. – saiarcot895 Jun 2 '14 at 23:31
still nothing. I tried adding brackets but all it did was add random brackets in the text I can see – mrnatbus12 Jun 3 '14 at 0:27

Looks like your pulling the time in 24hr format along with a "|" and a "-" and two ">>" try this string.

PS1="\[\033[0;34m\]\A | \[\033[0;31m-\] \[\033[0;32m\]>> "
share|improve this answer

You need to enclose the escape sequences in \[ \]:

PS1='\[\e[0;34m\]\A\[\e[m\] | \[\e[0;31m\]-\[\e[m\] \[\e[0;32m\]>>\[\e[m\]  '

This is essentially the same as @user107425's answer but using the \e instead of \033 syntax and with the closing \[\e[m\] that resets the color to the default after the end of the prompt.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.