1 ################################################################################
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 $
11 # (c) Copyright 2000-2005, Andrew@DeFaria.com, all rights reserved.
13 ################################################################################
14 # The following will set HOME, temporarily, to the directory of my $HOME so that
15 # somebody other than me can envoke my startup scripts. I use this mainly for
16 # when I become root with sudo -s and what a better environment that the bare
17 # bones root environment gives you. Note that for us to be effective one must
18 # source (or .) this file and if so the ${BASH_ARGV[0]} is the normal $0
19 if [ -n "${BASH_ARGV[0]}" ]; then
20 home=$(dirname ${BASH_ARGV[0]})
28 # Now set $HOME if $home is different.
30 if [ "$HOME" != "$home" ]; then
34 # Set ARCHITECTURE of the machine
36 if [[ $KERNEL = CYGWIN* ]]; then
37 export ARCHITECTURE=cygwin
38 elif [ $KERNEL = "Linux" ]; then
39 export ARCHITECTURE=linux
40 elif [ $KERNEL = "SunOS" ]; then
41 export ARCHITECTURE=sun
42 elif [ $KERNEL = "FreeBSD" ]; then
43 export ARCHITECTURE=$KERNEL
44 elif [ $KERNEL = "Darwin" ]; then
45 export ARCHITECTURE=$KERNEL
47 export ARCHITECTURE=''
48 echo "Warning: Unknown architecture ($KERNEL)"
51 # Hack: Just set TERM to xterm
52 if [ $ARCHITECTURE = 'sun' ]; then
59 if [ $ARCHITECTURE = 'cygwin' ]; then
67 if [ -f "$HOME/.rc/set_colors" ]; then
68 source "$HOME/.rc/set_colors"
70 echo "Warning: ~/.rc/set_colors does not exist!"
73 # Check to see if we're interactive
74 if [[ $- = *i* ]]; then
75 export interactive=true
77 export interactive=false
83 if [ "$TERM" = "" -o \
84 "$TERM" = "unknown" -o \
85 "$TERM" = "dialup" -o \
86 "$TERM" = "network" ]; then
87 if [ "$interactive" = "true" ]; then
88 eval $(ttytype -s -a -t ansi -t hp)
92 # System dependent variables.
93 if [ -f "$HOME/.rc/system" ]; then
94 source "$HOME/.rc/system"
96 echo "Warning ~/.rc/system does not exist!"
97 export SYSNAME="*Unknown Systemname*:"
102 if [ "$interactive" = "true" ]; then
103 stty tostop intr ^C kill ^X susp ^Z erase ^H -inpck -istrip -ixany -echok -echonl
107 adm_base=${adm_base:-/opt/clearscm}
110 adm_fpath=${adm_fpath:-$adm_base/functions}
113 if [ -f "$adm_fpath/common" ]; then
114 source "$adm_fpath/common"
116 : echo "Warning: Cannot find $adm_fpath/common!"
119 # Source bash_completion (if present) (too slow for Windows)
120 if [ -r /etc/bash_completion -a $ARCHITECTURE != "cygwin" ]; then
121 source /etc/bash_completion
125 if [ $ARCHITECTURE = "cygwin" ]; then
126 alias ping=$(echo $SYSTEMROOT | tr '\\' '\/')/system32/ping
130 # We specify /home/$USER here so that when we sudo to another user
131 # we will only trap logout if that user also has a ~/.rc/logout
133 if [ -x /home/$USER/.rc/logout ]; then
134 trap "/home/$USER/.rc/logout" 0
138 if [ -f ~/.rc/clearcase ]; then
139 source ~/.rc/clearcase
143 if [ -f ~/.rc/multisite ]; then
144 source ~/.rc/multisite
148 if [ -f ~/.rc/git ]; then
152 # Import shell functions:
153 if [ -f ~/.rc/functions ]; then
154 source ~/.rc/functions
163 if [ $ARCHITECTURE != 'Darwin' -a $ARCHITECTURE != 'sun' ]; then
164 ls /etc/*release > /dev/null 2>&1
167 if ! grep -qP '5\.(6|7|8|9|10)' /etc/*release; then
168 shopt -s autocd > /dev/null 2>&1
169 shopt -s dirspell > /dev/null 2>&1
179 if [ $ARCHITECTURE = "FreeBSD" -o $ARCHITECTURE = "Darwin" ]; then
182 if [ -f ~/.rc/dircolors ]; then
183 if type -p dircolors > /dev/null; then
184 eval $(dircolors -b ~/.rc/dircolors)
188 if [ $ARCHITECTURE = "sun" ]; then
189 # Ugh! --color doesn't work on braindead SUN
192 alias ls="ls -F --color=auto"
197 alias whence="type -p"
200 if [ $ARCHITECTURE = "cygwin" ]; then
204 if [ -f "$SYSTEMDRIVE/Perl64/bin/perl" ]; then
205 alias asperl="$SYSTEMDRIVE/Perl64/bin/perl"
208 if [ -f "$SYSTEMDRIVE/Perl/bin/perl" ]; then
209 alias asperl="$SYSTEMDRIVE/Perl64/bin/perl"
212 if [ $(locale -a | grep -c en_US.utf8) != 0 ]; then
213 export LANG=en_US.utf8
218 if [ "$(type -p vim)" ]; then
222 if [ "$(type -p ncftp)" ]; then
224 alias ftpput=ncftpput
225 alias ftpget=ncftpget
228 #alias grep="grep -d skip"
230 if [ "$TERM" = "hpterm" -o \
232 "$TERM" = "dtterm" -o \
233 "$TERM" = "sun-color" -o \
234 "$TERM" = "vt100" -o \
235 "$TERM" = "vt220" -o \
236 "$TERM" = "xtermc" -o \
237 "$TERM" = "xterm" -o \
238 "$TERM" = "xterm-256color" -o \
239 "$TERM" = "cygwin" ]; then
246 if [ -x $(type -p less) ]; then
247 export LESS=eiXP"?f%f :[stdin] .?pt(%pt\%):?bt(%bt bytes):-.."
248 alias more="less -sr"
249 export PAGER="less -sr"
255 export PS4='${0##*/} line $LINENO:'
260 if [ "$TERM" = "dtterm" ]; then
266 export MAIL=/var/mail/$USER
269 export PERLCRITIC=~/.rc/perlcriticrc
270 export PERLTIDY=~/.rc/perltidyrc
275 alias vbs="cscript //nologo"
278 if [ -f ~/.rc/set_path ]; then
279 source ~/.rc/set_path
281 echo "Warning: ~/.rc/set_path does not exist!"
284 # Color man pages with yellow keywords
285 export LESS_TERMCAP_md=$'\e[1;33m'
287 # If /opt/clearscm/lib is around then set PERL5LIB
288 if [ -d /opt/clearscm/lib ]; then
289 export PERL5LIB="$PERL5LIB:/opt/clearscm/lib"
293 if type lessfile > /dev/null 2>&1; then
297 # Client specific customizations
298 for script in $(\ls ~/.rc/client_scripts); do
299 # This is not working as long as ACLs are not supported from the remote
300 # NetApp. This happens at some clients where the home directory is on a
301 # Netapp and they do not support NTFS ACLs properly. We cannot determine
302 # if the script is executable.
303 #if [ ! -d ~/.rc/client_scripts/$script ]; then
304 if [ -x ~/.rc/client_scripts/$script -a \
305 ! -d ~/.rc/client_scripts/$script ]; then
306 source ~/.rc/client_scripts/$script
310 # Set display to local
312 export DISPLAY=${DISPLAY:-:0}
313 # Reset home in case it changed
316 # Odd but Eclipse's Egit can't seem to work with defaria.com unless this is set.
317 export GIT_SSH=/usr/bin/ssh
319 # Now go home (in case we were not autmatically cd'ed there)
320 if [ $($id -u) -ne 0 ]; then