[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Where is Bash Prompt Set??



On Wed, Feb 17, 2010 at 04:59:33AM -0600, Stan Hoeppner
wrote:
> Why is this a problem?  If I'm not logged in, why does
> this shell setup code need to be invoked.  Makes perfect
> sense to me that it is only invoked on login.  Am I
> missing something?

I should clarify.  This is only a problem if you are trying
to colour (or otherwise influence) the formatting of the
text you type at the root prompt. One of the OPs is trying
this. You are not.

For the poster who wanted to colour their root text by
opening an escape and not resetting it again, they will
need to ensure that there is a reset at some point between
their root prompt and their user prompt.

In your case, your user PS1 begins by resetting/closing the
formatting: that's one of the effects of the output of 
$(tput setaf 2).

If you were trying to do this, and your user's PS1 had some
text that came before your call to tput, it would be
coloured according to whatever formatting you had applied in
your root PS1.

> I have no idea where you came up with that.  What do you
> see that "suggests" this?

I have misunderstood what you were saying. When you revealed
you were not aware of CTRL+D I believed you must have been
switching authorisations by repeating 'su'. So you were
typing 'exit' or 'logout' every time instead?

> Believe me, of all people, if processes were left hanging
> around, _*I*_ would be the first to notice and fix ir.  I
> run Samba from inet to cut down on needless processes for
> Pete's sake. ;)  I'm a process efficiency freak.

Well, your user and root PS1s are invoking three tput(1)
processes for every command you enter. If you replace them
with raw escape sequences as in some of the other examples,
you'll save rather a lot of processes. (at the expense of
tying your PS1 to a particular terminal type. Do you
regularly use myriad terminal emulators?)


-- 
Jon Dowland

Attachment: signature.asc
Description: Digital signature


Reply to: