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

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

Path: ...!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 12:49:58 +0000
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <vikadn$3b35f$1@dont-email.me>
References: <874j3ml3q8.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 13:50:00 +0100 (CET)
Injection-Info: dont-email.me; posting-host="83b0557600b172a9e9bf2d22c7faa7e1";
	logging-data="3509423"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/bqXjqo+vO4f1JhFJS0qM4Cko9/2F1zHg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:hkZKnZy4v04UFYiJi7AfkNTbW2M=
In-Reply-To: <874j3ml3q8.fsf@example.com>
Content-Language: en-GB
Bytes: 2037

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.)

e.g.
# if running bash
if [ -n "$BASH_VERSION" ]; then
     # include .bashrc if it exists
     if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
     fi
fi

..profile is called by a login shell
..bashrc is called by interactive bash shell



-- 
Chris Elvidge, England
I WILL NOT SNAP BRAS