SCIENTIFIC-LINUX-USERS Archives

November 2017

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Sat, 11 Nov 2017 07:26:13 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (39 lines)
On Fri, Nov 10, 2017 at 9:48 PM, jdow <[log in to unmask]> wrote:
>
> Here is what I have in my .bash_profile file:
>
> if [ "$PS1" ]; then
> # extra [ in front of \u unconfuses confused Linux VT parser
> PS1="\e[0 [[\\u@\\h:\\l \\w]\\$ "
> fi

What do you mean by "VT parser"? Because whether you are on a VT or in
an xterm, not having "...[[\\u..." removes the opening square bracket
from PS1 (it, somehow, terminates the escape).

"\e[0" should be "\e[0m".

Since you're only using escaped characters, you can stop escaping the
backslashes:

th@localhost ~ $ PS1="\e[0 [[\u@\h:\l \w]\$ "
[th@localhost:0 ~]$ cd /etc
[th@localhost:0 /etc]$

If you use "\e[0m", you don't need "[[":

[th@localhost:0 /etc]$ PS1="\w $ "
/etc $ PS1="\e[0m[\u@\h:\l \w]\$ "
[th@localhost:0 /etc]$ cd /opt
[th@localhost:0 /opt]$ cd
[th@localhost:0 ~]$

You're supposed to enclose non-printing characters in escaped
brackets. PS1 expansion generally works without doing so but I've had
problems in the past when not using them (I can't remember under what
circumstances, sorry).

So it should be:

PS1="\[\e[0m\][\u@\h:\l \w]\$ "

ATOM RSS1 RSS2