08-31-2015, 12:45 PM
Oh, sorry mate. I was too tired last night.
Let's see...
The colors aren't properly escaped.
Variable expansion and the \[ \] escapes around them make them not count as character positions and the cursor position is not wrong.
This is the proper way to do it:
\[\e[1;31m\]foo
or
\[\e[1;31m\]\[$variable\]
If you want to set it up like this
jacatone@Dell-4550:~$ command...
You could also set it in two colors
jacatone@Dell-4550: ~$
From your first example I thought you were going to use the [ ] brackets:
[jacatone@Dell-4550~]$
Let's see...
The colors aren't properly escaped.
Variable expansion and the \[ \] escapes around them make them not count as character positions and the cursor position is not wrong.
This is the proper way to do it:
\[\e[1;31m\]foo
or
\[\e[1;31m\]\[$variable\]
If you want to set it up like this
jacatone@Dell-4550:~$ command...
Code:
export PS1="\[\e[1;31m\]\[\u@\h:\w\$\] \[\e[0m\] "
jacatone@Dell-4550: ~$
Code:
export PS1="\[\e[1;31m\]\[\u@\h\] \[\e[0;32m\]\[\W\$\] \[\e[0m\] "
[jacatone@Dell-4550~]$
Code:
export PS1="\[\e[1;31m\][\u@\h\w]\$ \[\e[0m\] "