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

Re: xdm source .bash_profile

On Sat, Jun 24, 2006 at 12:00:03AM +0200, Pavlos Parissis wrote:
> Hello all,
> I have been trying to make my X to source the .bash_profile in order
> to set my $PATH variable.

.xsession is the best place to deal with this, but you need to start
your X session in this file, or else it will just end.  For example,
my .xsession file looks like this:


    # start my X session

    if [ -f ~/.bashrc ]; then
    	. ~/.bashrc
    xrdb -merge .Xdefaults
    ssh-agent gnome-session
This starts gnome, and runs it from ssh-agent.  That's a neat trick
which makes your ssh agent accessible to all xterms started from
within your X session.  If you use KDE, replace that with startkde.

The key is, once this script ends, so does your X session.  If you
just source your .bashrc file, your X session will end before it has a
chance to start.  ;-)

> Since ~/.bashrc is invoked by no login shell I don't really mind to
> use this trick.  But, I do mind that fact that I have duplicate
> information, $PATH is set in two files.

The usual way to handle this is to put environment initialization
commands only in .bashrc, and source .bashrc from .profile (or
.bash_profile).  Note that you don't want to put commands which
generate output in .bashrc -- if you do this, it can cause problems
for your ssh sessions (particularly using scp, etc.) which will
receive the output of the .bashrc script, and corrupt the data stream.
To counteract that problem, only put commands which generate output in
.profile (or .bash_profile).


Derek D. Martin
GPG Key ID: 0x81CFE75D

Attachment: pgpiwOO4_tXRS.pgp
Description: PGP signature

Reply to: