I have Fedora 20, and I would like to adapt the bash prompt to make it even more useful to me. At present my PS1 prompt is set by these lines in my ~/.bash_profile file:
LP=" Last prompt at: "
PS1="\[\033[s\033[0;0H\033[0;47m\033[K\033[1;34m[\$LP\]t\033[0m\033[u[<\u@\h \W>]\$ "
echo
Which gives me a nice line at the top of the screen, with a grey bar (which does not show in this copy) and the time of the last prompt, thus:
[ Last prompt at: ]09:22:46
[<Harry@localhost ~>]$
Without the echo
, when a terminal screen is opened, the prompt obscures the message on the top line. What the echo does is to echo its argument, so that when .bashrc. is run as a new terminal is opened, with no argument it nicely goes to a new line, leaving the top line alone. Subsequent prompts do not run .bashrc so the echo to a new line does not happen.
My question here concerns the "[ ]" brackets in the prompt round the Last prompt at:
string. Please, how can I avoid these brackets appearing in the message displayed?
SOLVED
In response to @guido's answer. I had already tried just removing the square brackets, but then I lost the string completely. I note here that you have added a space after the LP, and that does indeed give me what I want, but I don't understand why the space is necessary: please could you add to your answer to explain that?
[
square brackets]
- in combination with other characters - and these serve similarly to"
quotes. It's a long string - my eyes are crossing - but you had at least one too many. Sorry for before.