view .bashrc @ 14:94cfcec3b5b6

When bash is called non-interactively, PS1 is unset. However, if it's a login shell, ~/.bash_profile is still sourced. Therefore, testing PS1 tells us if this is a login but non-interactive shell (such as: ssh host 'uptime'). Testing PS1 before setting it preserves that state for later tests if desired.
author huston@80426f53-59d1-405d-934b-f07cd76f4a1a
date Sun, 30 Aug 2009 06:49:10 +0000
parents dacbbae5965c
children b9896ae0733c
line wrap: on
line source

# .bashrc
# This file is sourced for shells which are interactive but not a
# login shell; however, since it is also sourced within
# $HOME/.bash_profile, the end result is that this file is sourced for all
# shells.


# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# User specific aliases and functions
if [ -f $HOME/.bash_aliases ]; then
   . $HOME/.bash_aliases
fi

#
# Environment variables
#
[[ "$PS1" ]] && export PS1='\h:\w\$ '
export PAGER=less
export EDITOR=vim
export RUBYLIB=$HOME/Installs/rubygems/lib
export GEM_HOME=$HOME/Installs/rubygems/gems

#
# Paths
#
# Standard-ish paths; some of these may be in place already, but if
# they're not they should probably go near the front of the pack.
for P in /sbin /usr/sbin /usr/local/bin /usr/local/sbin \
    /opt/local/bin /opt/local/sbin ; do
   [[ "$PATH" =~ "(^|:)$P($|:)" ]] || \
   export PATH=${P}${PATH:+:$PATH}
done

for M in /usr/local/share/man /usr/local/man /opt/local/share/man ; do
   [[ "$MANPATH" =~ "(^|:)$M($|:)" ]] || \
   export MANPATH=${M}${MANPATH:+:$MANPATH}
done

# Local Perl install
if [ -d $HOME/perl ]; then
   [[ "$PERL5LIB" =~ "(^|:)$HOME/perl($|:)" ]] || \
   export PERL5LIB=$HOME/perl${PERL5LIB:+:$PERL5LIB}

   if [ -d $HOME/perl/share/man ]; then
      [[ "$MANPATH" =~ "(^|:)$HOME/perl/share/man($|:)" ]] || \
      export MANPATH=$HOME/perl/share/man:${MANPATH:+$MANPATH}
   fi

   if [ -d $HOME/perl/bin ]; then
      [[ "$PATH" =~ "(^|:)$HOME/perl/bin($|:)" ]] || \
      export PATH=$HOME/perl/bin${PATH:+:$PATH}
   fi
fi

# Local install paths - install things to $HOME/Installs directories, and
# they will automatically get the proper paths added.  Most things
# that use autoconf will do this with
# './configure --prefix=$HOME/Installs'
for D in $HOME/Installs/* ; do
   if [ -d $D/bin ]; then 
      [[ "$PATH" =~ "(^|:)$D/bin($|:)" ]] || \
      export PATH=$D/bin${PATH:+:$PATH}
   fi

   if [ -d $D/share/man ]; then 
      [[ "$MANPATH" =~ "(^|:)$D/share/man($|:)" ]] || \
      export MANPATH=$D/share/man:${MANPATH:+$MANPATH}
   fi
   
   if [ -d $D/man ]; then 
      [[ "$MANPATH" =~ "(^|:)$D/man($|:)" ]] || \
      export MANPATH=$D/man:${MANPATH:+$MANPATH}
   fi
   
   if [ -d $D/lib ]; then 
      [[ "$LD_LIBRARY_PATH" =~ "(^|:)$D/lib($|:)" ]] || \
      export LD_LIBRARY_PATH=$D/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
   fi
done

# Add-ons for Intel compilers at work, and Condor
[[ -f /usr/peyton/intel/10.1/cc64/bin/iccvars.sh ]] && \
   . /usr/peyton/intel/10.1/cc64/bin/iccvars.sh
[[ -f /usr/peyton/intel/10.1/fc64/bin/ifortvars.sh ]] && \
   . /usr/peyton/intel/10.1/fc64/bin/ifortvars.sh
[[ -f /u/condor/condor-setup.sh ]] && {
   export PATH=${PATH:+$PATH:}/u/condor/hosts/`hostname -s`/sbin
   . /u/condor/condor-setup.sh
}

# Now make sure $HOME/bin is top of the list (or at least present)
if [ -d $HOME/bin ]; then
   [[ "$PATH" =~ "(^|:)$HOME/bin($|:)" ]] || \
   export PATH=$HOME/bin${PATH:+:$PATH}
fi

# Last, make sure to end MANPATH with a ':' to force include of system paths
# (some versions of man take care of this, but it doesn't hurt to have it
# anyway)
[[ "$MANPATH" =~ ":$" ]] || export MANPATH=$MANPATH: