.bashrc .profile .bash_profile
allbery at kf8nh.com
Thu Oct 1 17:21:07 PDT 2009
On Oct 1, 2009, at 17:41 , Scott Haneda wrote:
> I need to understand this once and for all, there is varying info on
> this, the bash man page is verbose and not entirely clear.
> When bash is invoked as an interactive login shell, or as a
> active shell with the --login option, it first reads and
> executes com-
> mands from the file /etc/profile, if that file exists.
> After reading
> that file, it looks for ~/.bash_profile, ~/.bash_login, and
> in that order, and reads and executes commands from the first
> one that
> exists and is readable. The --noprofile option may be used
> when the
> shell is started to inhibit this behavior.
> This implies, that only one of those files is read. That it stops
> once it finds one. I have:
> .bash_profile, .bashrc, and .profile
bash will read .bash_profile and .bashrc.
I would put bash-specific session-level information in .bash_profile,
portable (to e.g. zsh) session-level information in .profile, and
have .bash_profile source .profile. Per-shell information should go
in .bashrc. But I've been doing this stuff for a while, and I can
imagine people hndling single files better. (I also use the same
shell config files on every system I use, which is a rather wide array
of operating systems and versions.)
Normally it is a good idea not to put environment settings, stty
settings, etc. in .bashrc.
> I am pretty sure I need to stop using .bashrc, since that is for
> interactive non login shells, which I am interpreting as shells that
> do work that is not the result of me using the shell.
When you open a Terminal window, (by default) you get an interactive
If you type "bash" in that shell, you get an interactive non-login
If you run vi and type ":!ls", vi will spawn a noninteractive shell to
run "ls". Noninteractive shells are also used by "make", "port", and
numerous other commands.
> Sounds to me, like the correct course of action is to put my custom
> shell aliases and settings
Shell aliases should be in .bashrc.
> This brings up a question, if the .bash* files do not cascade, and
> stop after finding your local one, how is it that MacPorts suggests
> to use .profile, as that will never get read?
MacPoerts assumes you don't use the shell-specific .bash_profile
or .bash_login, or if you do you also "source .profile". I would
consider the latter a best practice.
> On a side note, I am doing this:
> export LSCOLORS=dxfxcxdxbxegedabagacad
> Which has never worked for me on a non darwin OS.
On many systems it's LS_COLORS, not LSCOLORS, and it has a different
> Is that the wrong way to do it, are there more appropriate ways to
> do coloring? I think having this in .bashrc actually hurt me ones,
> as MacPorts saw either:
> export CLICOLOR=1 or export CLICOLOR_FORCE=1
CLICOLOR_FORCE will probably cause scripts that use ls to break pretty
badly. MacPorts is itself implemented using scripts.
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 195 bytes
Desc: This is a digitally signed message part
More information about the macports-users