Deutsch   English   Français   Italiano  
<vil5ut$3ic43$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Chris Elvidge <chris@internal.net>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: which file should have my bash prompt, .profile vs .bashrc
Date: Mon, 2 Dec 2024 20:39:56 +0000
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <vil5ut$3ic43$1@dont-email.me>
References: <874j3ml3q8.fsf@example.com> <vikadn$3b35f$1@dont-email.me>
 <87a5dejb0e.fsf@example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 02 Dec 2024 21:39:58 +0100 (CET)
Injection-Info: dont-email.me; posting-host="851009f107b11d69a95a03c84804a590";
	logging-data="3747971"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19yVHH3HqSPeYq4Vtv0AaTvoGvUyW6J1i0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:HatPvQ48/Oi6013zGa6LCC4PI+g=
Content-Language: en-GB
In-Reply-To: <87a5dejb0e.fsf@example.com>
Bytes: 2651

On 02/12/2024 at 16:38, Wolfgang Agnes wrote:
> Chris Elvidge <chris@internal.net> writes:
> 
>> On 02/12/2024 at 11:32, Wolfgang Agnes wrote:
>>> I installed bash and have been trying to set up my prompt.  I notice
>>> that if I add
>>>     PS1='# '; export PS1
>>> to my .profile, then I get the prompt when I log in, not when I
>>> /sudo
>>> su/ from a regular user.  If I add
>>>     PS1='# '; export PS1
>>> to ~/.bashrc, then I get the prompt when I ``sudo su'', but not when
>>> I
>>> log in.  I can add the prompt set up to both files, but I'm asking
>>> myself---how do you guys avoid such redundancy?  (Thanks!)
>>>
>>
>> Put it in .bashrc and then call .bashrc from .profile (unless
>> .bash_profile exists; only for bash.)
> 

Slackware user here.

> Is this how it's typically done?  I thought that sourcing .profile, say,
> from .bashrc would destroy the purpose of having a separate thing for

No. Source .bashrc from .profile only if $BASH_VERSION is set.
Also .bash_profile will not be used if shell is not bash.

> when logging in and another for interactive runs of the shell.  Now
> realize I could make a library-script and source it from both scripts
> (.profile and .bashrc), but then I've never done that myself and so I
> was wondering how people do things.
> 
> Anyway, thanks very much for sharing your side of things!
> 



-- 
Chris Elvidge, England
I WILL NOT SPANK OTHERS