1

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
2
  • 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. Jun 2, 2014 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, 2014 at 0:27

1 Answer 1

0

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.

You must log in to answer this question.

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