PS1 bash prompt with new line and color
I am trying to create a bash prompt with new line and color.
The first three prompts behave as expected: Code:
PS1="[]\$ " # 1) simple prompt: []$ Code:
$ export PS1="\e[1;33m[]\n\$\e[m " What wrong with the exported prompt? Thank you. |
Bash can be funny with escape codes.
Try the suggestion here, http://stackoverflow.com/questions/7...ompt-correctly, see if that helps. |
Quote:
The link is about the \[...\] sequence. My problem prompt "\e[1;33m[]\n\$\e[m " contains neither \[ nor \]. |
This works:
Code:
export PS1="\e[1;33m[]\e[m\n\$ " |
Unless you are expanding any variables inside (which can be problematic and a pain) I would suggest using single quotes so as to not have anything interpreted prior to being assigned.
|
|
Quote:
|
Try \033 instead of \e. What I had to do for a bash script that does color. It's the octal value for e.
|
solved
Quote:
Now I see what you mean. Thanks for your patients. This works as intended: Code:
$ export PS1="\[\e[1;33m\][]\n$\[\e[m\] " The command prompt dissected: Code:
export PS1="\[ \e[1;33m \] [] \n $ \[ \e[m \] " |
Good job and well done.
I had to do some kungfu on my PS1 to get this a few years ago. Code:
DOS='C:${PWD//\//\\\}>' Have fun! PS1 was the first thing I "programmed" in Linux. Enjoyed it every minute. |
All times are GMT -5. The time now is 08:20 PM. |