comparison .bashrc @ 4:6ffd3fb73f7f

s/\~\//\$HOME\//g - There's possibly a nicer way to make sure tilde expansion is done in the right places, but this works just as well and doesn't require extra thinking when I'm half asleep :P Added (^|:) to start, and ($|:) to end of all tests to make sure we're matching a full path. Also test for (and append if not there) a ':' at the end of $MANPATH; otherwise Linux systems tend to forget how to search system paths.
author huston@80426f53-59d1-405d-934b-f07cd76f4a1a
date Sat, 11 Apr 2009 06:54:02 +0000
parents 072b183989e0
children 3d0de329a850
comparison
equal deleted inserted replaced
3:072b183989e0 4:6ffd3fb73f7f
1 # .bashrc 1 # .bashrc
2 # This file is sourced for shells which are interactive but not a 2 # This file is sourced for shells which are interactive but not a
3 # login shell; however, since it is also sourced within 3 # login shell; however, since it is also sourced within
4 # ~/.bash_profile, the end result is that this file is sourced for all 4 # $HOME/.bash_profile, the end result is that this file is sourced for all
5 # shells. 5 # shells.
6 6
7 7
8 # Source global definitions 8 # Source global definitions
9 if [ -f /etc/bashrc ]; then 9 if [ -f /etc/bashrc ]; then
27 # 27 #
28 # Standard-ish paths; some of these may be in place already, but if 28 # Standard-ish paths; some of these may be in place already, but if
29 # they're not they should probably go near the front of the pack. 29 # they're not they should probably go near the front of the pack.
30 for P in /sbin /usr/sbin /usr/local/bin /usr/local/sbin \ 30 for P in /sbin /usr/sbin /usr/local/bin /usr/local/sbin \
31 /opt/local/bin /opt/local/sbin ; do 31 /opt/local/bin /opt/local/sbin ; do
32 [[ "$PATH" =~ $P ]] || \ 32 [[ "$PATH" =~ "(^|:)$P($|:)" ]] || \
33 export PATH=${P}${PATH:+:$PATH} 33 export PATH=${P}${PATH:+:$PATH}
34 done 34 done
35 35
36 for M in /usr/local/share/man /usr/local/man /opt/local/share/man ; do 36 for M in /usr/local/share/man /usr/local/man /opt/local/share/man ; do
37 [[ "$MANPATH" =~ $M ]] || \ 37 [[ "$MANPATH" =~ "(^|:)$M($|:)" ]] || \
38 export MANPATH=${M}${MANPATH:+:$MANPATH} 38 export MANPATH=${M}${MANPATH:+:$MANPATH}
39 done 39 done
40 40
41 # Local Perl install 41 # Local Perl install
42 if [ -d ~/perl ]; then 42 if [ -d $HOME/perl ]; then
43 [[ "$PERL5LIB" =~ ~/perl ]] || \ 43 [[ "$PERL5LIB" =~ "(^|:)$HOME/perl($|:)" ]] || \
44 export PERL5LIB=~/perl${PERL5LIB:+:$PERL5LIB} 44 export PERL5LIB=$HOME/perl${PERL5LIB:+:$PERL5LIB}
45 45
46 if [ -d ~/perl/share/man ]; then 46 if [ -d $HOME/perl/share/man ]; then
47 [[ "$MANPATH" =~ ~/perl/share/man ]] || \ 47 [[ "$MANPATH" =~ "(^|:)$HOME/perl/share/man($|:)" ]] || \
48 export MANPATH=~/perl/share/man:${MANPATH:+$MANPATH} 48 export MANPATH=$HOME/perl/share/man:${MANPATH:+$MANPATH}
49 fi 49 fi
50 50
51 if [ -d ~/perl/bin ]; then 51 if [ -d $HOME/perl/bin ]; then
52 [[ "$PATH" =~ ~/perl/bin ]] || \ 52 [[ "$PATH" =~ "(^|:)$HOME/perl/bin($|:)" ]] || \
53 export PATH=~/perl/bin${PATH:+:$PATH} 53 export PATH=$HOME/perl/bin${PATH:+:$PATH}
54 fi 54 fi
55 fi 55 fi
56 56
57 # Local install paths - install things to ~/Installs directories, and 57 # Local install paths - install things to $HOME/Installs directories, and
58 # they will automatically get the proper paths added. Most things 58 # they will automatically get the proper paths added. Most things
59 # that use autoconf will do this with 59 # that use autoconf will do this with
60 # './configure --prefix=~/Installs' 60 # './configure --prefix=$HOME/Installs'
61 for D in ~/Installs/* ; do 61 for D in $HOME/Installs/* ; do
62 if [ -d $D/bin ]; then 62 if [ -d $D/bin ]; then
63 [[ "$PATH" =~ "$D/bin" ]] || \ 63 [[ "$PATH" =~ "(^|:)$D/bin($|:)" ]] || \
64 export PATH=$D/bin${PATH:+:$PATH} 64 export PATH=$D/bin${PATH:+:$PATH}
65 fi 65 fi
66 66
67 if [ -d $D/share/man ]; then 67 if [ -d $D/share/man ]; then
68 [[ "$MANPATH" =~ "$D/share/man" ]] || \ 68 [[ "$MANPATH" =~ "(^|:)$D/share/man($|:)" ]] || \
69 export MANPATH=$D/share/man:${MANPATH:+$MANPATH} 69 export MANPATH=$D/share/man:${MANPATH:+$MANPATH}
70 fi 70 fi
71 71
72 if [ -d $D/man ]; then 72 if [ -d $D/man ]; then
73 [[ "$MANPATH" =~ "$D/man" ]] || \ 73 [[ "$MANPATH" =~ "(^|:)$D/man($|:)" ]] || \
74 export MANPATH=$D/man:${MANPATH:+$MANPATH} 74 export MANPATH=$D/man:${MANPATH:+$MANPATH}
75 fi 75 fi
76 76
77 if [ -d $D/lib ]; then 77 if [ -d $D/lib ]; then
78 [[ "$LD_LIBRARY_PATH" =~ "$D/lib" ]] || \ 78 [[ "$LD_LIBRARY_PATH" =~ "(^|:)$D/lib($|:)" ]] || \
79 export LD_LIBRARY_PATH=$D/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} 79 export LD_LIBRARY_PATH=$D/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
80 fi 80 fi
81 done 81 done
82 82
83 # Now make sure ~/bin is top of the list 83 # Now make sure $HOME/bin is top of the list (or at least present)
84 if [ -d ~/bin ]; then 84 if [ -d $HOME/bin ]; then
85 [[ "$PATH" =~ ~/bin ]] || \ 85 [[ "$PATH" =~ "(^|:)$HOME/bin($|:)" ]] || \
86 export PATH=~/bin${PATH:+:$PATH} 86 export PATH=$HOME/bin${PATH:+:$PATH}
87 fi 87 fi
88
89 # Last, make sure to end MANPATH with a ':' to force include of system paths
90 # (some versions of man take care of this, but it doesn't hurt to have it
91 # anyway)
92 [[ "$MANPATH" =~ ":$" ]] || export MANPATH=$MANPATH: