Added client_script Audience and some shopt's.
[clearscm.git] / rc / bash_login
1 ################################################################################
2 #
3 # File:         $RCSfile: bash_login,v $
4 # Revision:         $Revision: 1.29 $
5 # Description:  bash startup file
6 # Author:       Andrew@DeFaria.com
7 # Created:      Mon Aug 20 17:35:01  2001
8 # Modified:     $Date: 2013/06/13 14:04:55 $
9 # Language:     bash
10 #
11 # (c) Copyright 2000-2005, Andrew@DeFaria.com, all rights reserved.
12 #
13 ################################################################################
14 # Set ARCHITECTURE of the machine
15 KERNEL=$(uname -s)
16 if [[ $KERNEL = CYGWIN* ]]; then
17   export ARCHITECTURE=cygwin
18 elif [ $KERNEL = "Linux" ]; then
19   export ARCHITECTURE=linux
20 elif [ $KERNEL = "SunOS" ]; then
21   export ARCHITECTURE=sun
22 elif [ $KERNEL = "FreeBSD" ]; then
23   export ARCHITECTURE=$KERNEL
24 else
25   export ARCHITECTURE=''
26   echo "Warning: Unknown architecture ($KERNEL)"
27 fi
28
29 # Architectual differences (AKA Silly Sun)
30 if [ $ARCHITECTURE = "sun" ]; then
31   alias id=/usr/xpg4/bin/id
32   alias tr=/usr/xpg4/bin/tr
33   
34   export id=/usr/xpg4/bin/id
35 fi
36
37 # Set colors
38 if [ -f "$HOME/.rc/set_colors" ]; then
39    source "$HOME/.rc/set_colors"
40 else
41   echo "Warning: ~/.rc/set_colors does not exist!"
42 fi
43
44 # Check to see if we're interactive
45 if [[ $- = *i* ]]; then
46   export interactive=true
47 else
48   export interactive=false
49 fi
50
51 export VISUAL=vi
52
53 # Terminal settings:
54 if [ "$TERM" = ""        -o \
55      "$TERM" = "unknown" -o \
56      "$TERM" = "dialup"  -o \
57      "$TERM" = "network" ]; then
58   if [ "$interactive" = "true" ]; then
59     eval $(ttytype -s -a -t ansi -t hp)
60   fi
61 fi
62
63 # System dependent variables.
64 if [ -f "$HOME/.rc/system" ]; then
65    source "$HOME/.rc/system"
66 else
67    echo "Warning ~/.rc/system does not exist!"
68    export SYSNAME="*Unknown Systemname*:"
69 fi
70
71 # System dependencies
72 # Note: I don't like doing this but an alias doesn't work...
73 if [ $ARCHITECTURE = "sun" ]; then
74   id=/usr/xpg4/bin/id
75 else
76   id=id
77 fi
78
79 umask 002
80
81 if [ "$interactive" = "true" ]; then
82   stty tostop intr ^C kill ^X susp ^Z erase ^H -inpck -istrip -ixany -echok -echonl
83 fi
84
85 # Set adm_base
86 adm_base=${adm_base:-/opt/clearscm}
87
88 # Set adm_fpath
89 adm_fpath=${adm_fpath:-$adm_base/functions}
90
91 # Source functions
92 if [ -f "$adm_fpath/common" ]; then
93   source "$adm_fpath/common"
94 else
95   : echo "Warning: Cannot find $adm_fpath/common!"
96 fi
97
98 # Source bash_completion (if present) (too slow for Windows)
99 if [ -r /etc/bash_completion -a $ARCHITECTURE != "cygwin" ]; then
100   source /etc/bash_completion
101 fi
102
103 if [ -x ~/.rc/logout ]; then
104   trap "~/.rc/logout" 0
105 fi
106
107 # ClearCase Stuff
108 if [ -f ~/.rc/clearcase ]; then
109   source ~/.rc/clearcase
110 fi
111
112 # MultiSite Stuff
113 if [ -f ~/.rc/multisite ]; then
114   source ~/.rc/multisite
115 fi
116
117 # Git Stuff
118 if [ -f ~/.rc/git ]; then
119   source ~/.rc/git
120 fi
121
122 # Import shell functions:
123 if [ -f ~/.rc/functions ]; then
124   source ~/.rc/functions
125 fi
126
127 # Other settings:
128 set -o emacs
129 set -o monitor
130 set +u
131
132 # Shell options
133 shopt -s autocd
134 shopt -s cdspell
135 shopt -s dirspell
136 shopt -s histappend
137 shopt -s lithist
138
139 # Aliases:
140 if [ $ARCHITECTURE = "FreeBSD" ]; then
141   alias ls="ls -FG"
142 else
143   if [ -f ~/.rc/dircolors ]; then
144     if type -p dircolors > /dev/null; then
145       eval $(dircolors -b ~/.rc/dircolors)
146     fi
147   fi
148
149   if [ $ARCHITECTURE = "sun" ]; then
150     # Ugh! --color doesn't work on braindead SUN
151     alias ls="ls -F"
152   else        
153     alias ls="ls -F --color=auto"
154   fi
155 fi
156
157 alias ll="ls -la"
158 alias whence="type -p"
159 alias mroe=more
160
161 if [ $ARCHITECTURE = "cygwin" ]; then
162   alias host=nslookup
163 fi
164
165 if [ -f "$SYSTEMDRIVE/Perl64/bin/perl" ]; then
166   alias asperl="$SYSTEMDRIVE/Perl64/bin/perl"
167 fi
168
169 if [ -f "$SYSTEMDRIVE/Perl/bin/perl" ]; then
170   alias asperl="$SYSTEMDRIVE/Perl64/bin/perl"
171 fi
172   
173 export LANG=C
174
175 if [ $(type -p vim) ]; then
176   alias vi=vim
177 fi
178
179 if [ $(type -p ncftp) ]; then
180   alias ftp=ncftp
181   alias ftpput=ncftpput
182   alias ftpget=ncftpget
183 fi
184
185 #alias grep="grep -d skip"
186
187 if [ "$TERM" = "hpterm"    -o \
188      "$TERM" = "hp"        -o \
189      "$TERM" = "dtterm"    -o \
190      "$TERM" = "sun-color" -o \
191      "$TERM" = "vt100"     -o \
192      "$TERM" = "vt220"     -o \
193      "$TERM" = "xterm"     -o \
194      "$TERM" = "cygwin" ]; then
195   alias cd=mycd
196   alias pushd=mypushd
197   alias popd=mypopd
198 fi
199
200 # Miscellaneous:
201 if [ -x $(type -p less) ]; then
202    export LESS=eiXP"?f%f :[stdin] .?pt(%pt\%):?bt(%bt bytes):-.."
203    alias more="less -sr"
204    export PAGER="less -sr"
205 else 
206    export MORE=-s
207    export PAGER=more
208 fi
209
210 export PS4='${0##*/} line $LINENO:'
211
212 set_title
213 set_prompt
214
215 if [ "$TERM" = "dtterm" ]; then
216   export TERM=vt100
217   export DTTERM=True
218 fi
219
220 # Set mail
221 export MAIL=/var/mail/$USER
222
223 # Perl Environment                                                              
224 export PERLCRITIC=~/.rc/perlcriticrc                                            
225 export PERLTIDY=~/.rc/perltidyrc                                                
226
227 # CDPATH
228 export CDPATH="."
229
230 alias vbs="cscript //nologo"
231
232 # Set PATH
233 if [ -f ~/.rc/set_path ]; then
234   source ~/.rc/set_path
235 else
236   echo "Warning: ~/.rc/set_path does not exist!"
237 fi
238
239 # Color man pages with yellow keywords
240 export LESS_TERMCAP_md=$'\e[1;33m'
241
242 # If /opt/clearscm/lib is around then set PERL5LIB
243 if [ -d /opt/clearscm/lib ]; then
244   export PERL5LIB="$PERL5LIB:/opt/clearscm/lib"
245 fi
246
247 # Client specific customizations
248 for script in $(\ls ~/.rc/client_scripts); do
249   # This is not working as long as ACLs are not supported from the remote
250   # NetApp. This happens at some clients where the home directory is on a
251   # Netapp and they do not support NTFS ACLs properly. We cannot determine
252   # if the script is executable.
253   #if [ ! -d ~/.rc/client_scripts/$script ]; then
254   if [ -x ~/.rc/client_scripts/$script -a \
255      ! -d ~/.rc/client_scripts/$script ]; then
256     source ~/.rc/client_scripts/$script
257   fi
258 done
259
260 # Set display to local
261 export DISPLAY=${DISPLAY:-:0}
262
263 # Now go home (in case we were not autmatically cd'ed there)
264 if [ $(id -u) -ne 0 ]; then
265   cd
266 fi