Moved git stuff to rc/git
[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 export CVSROOT=:ext:andrew@clearscm.com:/var/cvs/cvsroot
104
105 if [ -x ~/.rc/logout ]; then
106   trap "~/.rc/logout" 0
107 fi
108
109 # ClearCase Stuff
110 if [ -f ~/.rc/clearcase ]; then
111   source ~/.rc/clearcase
112 fi
113
114 # MultiSite Stuff
115 if [ -f ~/.rc/multisite ]; then
116   source ~/.rc/multisite
117 fi
118
119 # Git Stuff
120 if [ -f ~/.rc/git ]; then
121   source ~/.rc/git
122 fi
123
124 # Import shell functions:
125 if [ -f ~/.rc/functions ]; then
126   source ~/.rc/functions
127 fi
128
129 # Other settings:
130 set -o emacs
131 set -o monitor
132 set +u
133
134 shopt -s lithist
135
136 # Aliases:
137 if [ $ARCHITECTURE = "FreeBSD" ]; then
138   alias ls="ls -FG"
139 else
140   if [ -f ~/.rc/dircolors ]; then
141     if type -p dircolors > /dev/null; then
142       eval $(dircolors -b ~/.rc/dircolors)
143     fi
144   fi
145
146   if [ $ARCHITECTURE = "sun" ]; then
147     # Ugh! --color doesn't work on braindead SUN
148     alias ls="ls -F"
149   else
150     alias ls="ls -F --color=auto"
151   fi
152 fi
153
154 alias ll="ls -la"
155 alias whence="type -p"
156 alias mroe=more
157
158 if [ $ARCHITECTURE = "cygwin" ]; then
159   alias host=nslookup
160 fi
161
162 export LANG=C
163
164 if [ $(type -p vim) ]; then
165   alias vi=vim
166 fi
167
168 if [ $(type -p ncftp) ]; then
169   alias ftp=ncftp
170   alias ftpput=ncftpput
171   alias ftpget=ncftpget
172 fi
173
174 #alias grep="grep -d skip"
175
176 if [ "$TERM" = "hpterm"    -o \
177      "$TERM" = "hp"        -o \
178      "$TERM" = "dtterm"    -o \
179      "$TERM" = "sun-color" -o \
180      "$TERM" = "vt100"     -o \
181      "$TERM" = "vt220"     -o \
182      "$TERM" = "xterm"     -o \
183      "$TERM" = "cygwin" ]; then
184   alias cd=mycd
185   alias pushd=mypushd
186   alias popd=mypopd
187 fi
188
189 # Miscellaneous:
190 if [ -x $(type -p less) ]; then
191    export LESS=eiXP"?f%f :[stdin] .?pt(%pt\%):?bt(%bt bytes):-.."
192    alias more="less -sr"
193    export PAGER="less -sr"
194 else 
195    export MORE=-s
196    export PAGER=more
197 fi
198
199 export PS4='${0##*/} line $LINENO:'
200
201 set_title
202 set_prompt
203
204 if [ "$TERM" = "dtterm" ]; then
205   export TERM=vt100
206   export DTTERM=True
207 fi
208
209 # Set mail
210 export MAIL=/var/mail/$USER
211
212 # Perl Environment                                                              
213 export PERLCRITIC=~/.rc/perlcriticrc                                            
214 export PERLTIDY=~/.rc/perltidyrc                                                
215
216 # CDPATH
217 export CDPATH="."
218
219 alias vbs="cscript //nologo"
220
221 # Set PATH
222 if [ -f ~/.rc/set_path ]; then
223   source ~/.rc/set_path
224 else
225   echo "Warning: ~/.rc/set_path does not exist!"
226 fi
227
228 # Color man pages with yellow keywords
229 export LESS_TERMCAP_md=$'\e[1;33m'
230
231 # If /opt/clearscm/lib is around then set PERL5LIB
232 if [ -d /opt/clearscm/lib ]; then
233   export PERL5LIB="$PERL5LIB:/opt/clearscm/lib"
234 fi
235
236 # Client specific customizations
237 for script in $(\ls ~/.rc/client_scripts); do
238   # This is not working as long as ACLs are not supported from the remote
239   # NetApp. This happens at some clients where the home directory is on a
240   # Netapp and they do not support NTFS ACLs properly. We cannot determine
241   # if the script is executable.
242   #if [ ! -d ~/.rc/client_scripts/$script ]; then
243   if [ -x ~/.rc/client_scripts/$script -a \
244      ! -d ~/.rc/client_scripts/$script ]; then
245     source ~/.rc/client_scripts/$script
246   fi
247 done
248
249 # Set display to local
250 export DISPLAY=${DISPLAY:-:0}
251
252 # Now go home (in case we were not autmatically cd'ed there)
253 if [ $(id -u) -ne 0 ]; then
254   cd
255 fi