[GLLUG] bash madness

Ben Pfaff blp@cs.stanford.edu
19 Jul 2002 12:51:03 -0700


Brian Hoort <hoortbri@msu.edu> writes:

> I've been trying to customize my bash shell prompt. When I do an export 
> PS1... it works fine, obviously. However, when I set it in .bashrc and 
> re-login it does not take effect. A look at .bashrc reveals that:
> 
> # ~/.bashrc: executed by bash(1) for non-login shells.
> 
> So I presume that logging in is a login shell.
> 
> 1) What is a login shell as opposed to a non-login shell;

A login shell is the one that starts up when you log in.
Subshells, non-interactive shells, etc., are non-login shells.

> 2) So why is there a .bashrc if it's not going to be run.

It's only run for non-login shells.

> 3) Where do I set PS1, if not in .bashrc

.profile is executed for login shells.  If you want .bashrc to be
executed too then just add
        . $HOME/.bashrc
as the last line of your .profile.

About prompts: I use
        PS1='\u@\h:\w($?)\$ '
because I like to see who I am logged in as, the host I'm logged
into, the current directory, and the exit code of the last
command I ran.
-- 
"I was born lazy.  I am no lazier now than I was forty years ago, 
 but that is because I reached the limit forty years ago.  You can't 
 go beyond possibility."
--Mark Twain