Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac
share|improve this question
    
For reference, here are the lines from a standard .bashrc relevant to PS1: paste.ubuntu.com/7576468. My guess is that you don't have any closing brackets in your PS1. –  saiarcot895 Jun 2 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 at 0:27

2 Answers 2

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

 
discard

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.