+Support overriding by: /net/jes-v65-0.czech.sun.com/export/jscqa-local
[nethome.git] / .bashrc
1 if [ -z "$_home_short_dotbashrc" ];then
2         _home_short_dotbashrc=true
3
4 if [ -f /etc/bashrc ];then source /etc/bashrc;fi
5
6 function _bash_profile_addpath  # <variablename>,<dirpathname>
7 {
8         _OPTIND="$OPTIND"
9         _opt_f=0;_opt_s=0
10         OPTIND=1;while getopts fs got;do
11                 case "$got" in
12                         [fs]) eval "_opt_$got=1" ;;
13                         *) exit 1 ;;
14                         esac
15                 done
16         eval "_varname=\"\$$[$OPTIND+0]\""
17         eval "_dirpathname=\"\$$[$OPTIND+1]\""
18         if [ $_opt_f = 0 -a '!' -d "$_dirpathname" ];then return;fi
19         if [ $_opt_s = 1 -o -z "`eval "echo \\${$_varname}"`" ];then
20                 eval "$_varname='$_dirpathname'"
21         else
22                 # we want to override any original directories, place dirpathname first!
23                 eval "$_varname=\"$_dirpathname:\${$_varname}\""
24         fi
25         export "$_varname"
26         unset _varname _dirpathname _opt_f _opt_s
27         OPTIND="$_OPTIND";unset _OPTIND
28 }
29
30 # Use reverse order of preferred directories:
31 # gid(1) dependency on: /opt/sfw/bin
32 # EUID="`id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null || gid -u`"
33 _bash_profile_addpath -f PATH            "/sbin"
34 _bash_profile_addpath -f PATH            "/usr/sbin"
35 _bash_profile_addpath -f PATH            "/usr/dist/exe"
36 _bash_profile_addpath -f PATH            "/opt/sfw/bin"
37 _bash_profile_addpath -f PATH            "/share/ProductivityTools/exe"
38 _bash_profile_addpath -f PATH            "/usr/local/sbin"
39 _bash_profile_addpath -f PATH            "/usr/local/bin"
40 [ $EUID -eq 0 ] && _bash_profile_addpath -f PATH "/usr/local/sbin"
41 _bash_profile_addpath -f LD_LIBRARY_PATH "/opt/sfw/lib"
42 _bash_profile_addpath -f MANPATH         "/usr/X11R6/man"
43 _bash_profile_addpath -f MANPATH         "/usr/share/man"
44 _bash_profile_addpath -f MANPATH         "/usr/local/man"
45 [ "`uname`" = "SunOS" ] && _bash_profile_addpath -f LD_LIBRARY_PATH "$HOME/Netscape/dist/lib"
46 for family in "$HOME" "/net/jes-v65-0.czech.sun.com/export/jscqa-local";do
47         for arch in "$family" $family/`uname -p`;do
48                 # Do not "-f": We use /net !
49                 _bash_profile_addpath PATH            "$arch/bin"
50                 [ $EUID -eq 0 ] && _bash_profile_addpath PATH "$arch/sbin"
51                 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib"
52                 _bash_profile_addpath MANPATH         "$arch/man"
53                 done
54         done
55 _bash_profile_addpath -f -s CVSROOT "short@vellum.cz:/home/short/pserver/cvs"   # default
56 _bash_profile_addpath    -s CVSROOT "$HOME/pserver/cvs"
57 _bash_profile_addpath    -s CVSROOT "$HOME/cvs"
58 _bash_profile_addpath    -s JAVA_HOME "/usr/java"
59 _bash_profile_addpath    -s ANT_HOME "/usr/local/ant"
60
61 mkdir -p $HOME/lib/perl5        # otherwise CPAN will install to "$HOME/lib/site_perl" etc.
62 for _perldir in $(eval "echo {/usr,$HOME}/lib/perl5{,/site_perl}$(
63         for perlvar in version archname;do
64                 echo -n '{,/'
65                 perl -V:"$perlvar"|cut -d "'" -f 2|tr -d '\n'
66                 echo -n '}'
67                 done
68         )");do
69         _bash_profile_addpath -f PERLLIB "$_perldir"
70         done
71 unset _perldir
72
73 ### HiveMind_2.0_ga_u6.tar.gz/HiveMindGettingStarted.pdf:26
74 _bash_profile_addpath -f PATH "/opt/SUNWhvmd/framework/sparc-sun-solaris/bin"
75 _bash_profile_addpath -f LD_LIBRARY_PATH "/opt/SUNWhvmd/framework/sparc-sun-solaris/lib"
76 _bash_profile_addpath -f -s HM_PKG_BASE_DIR "/opt/SUNWhvmd"
77 _bash_profile_addpath -f -s HM_BASE_DIRS "/opt/SUNWhvmd/examples/tasks"
78 _bash_profile_addpath -f CLASSPATH "/opt/SUNWhvmd/launcher/GUI/classes/launcher.jar"
79
80 unset -f _bash_profile_addpath
81
82 for i in tar ls find cp mv ln md5sum du grep ar chown chmod tail;do
83         which g$i 2>/dev/null | grep '^/' >/dev/null && alias $i=g$i
84         done
85
86 alias ls='ls -bF'
87 alias l='ls -lbF'
88 alias maple="ssh -t vega.fjfi.cvut.cz maple"
89 #alias cc='cc -I/home/short/include'
90 alias vi='vim'
91 alias grepb='grep --binary-files=binary'
92 alias L='lynx'
93 alias cvsfiles='cvsutil --files --print'
94 alias cvsignores='cvsutil --ignores --print'
95 alias cvsignoresall='cvsutil --ignores --workings --print'
96 alias cvsignoresrm='cvsutil --ignores --rm'
97 alias cvsignoresrmall='cvsutil --ignores --workings --rm'
98 alias cvsignoresallrm='cvsutil --ignores --workings --rm'
99
100 weberr="/var/log/httpd/error/klokan.error_log"
101 if [ -f "$weberr" ];then alias weberr='tail "$weberr"';fi
102 weblog="/var/log/httpd/klokan.access_log"
103 if [ -f "$weblog" ];then alias weblog='tail -n 20000 "$weblog"|grep "\\(~\\|%7[eE]\\)short"';fi
104
105 export IGNOREEOF=10
106 export TMOUT=900
107 export EDITOR='vim'
108 [ -x /bin/less ] && export PAGER='/bin/less -MMh5cis'
109 [ "`uname`" = "SunOS" ] || export LC_CTYPE=cs_CZ.ISO-8859-2
110 export PERL_MM_OPT="PERL=$HOME/bin/perlilib PREFIX=$HOME"
111 for file in $HOME/.bookmarks.html;do
112         export WWW_HOME="file://$HOME/"
113         [ -r $file ] && export WWW_HOME="file://$file"
114         done
115 export GREP_OPTIONS="--binary-files=without-match --directories=skip"
116 if [ -n "$PS1" ];then   # set only in interactive sessions
117         export PS1="${USER}[bash]@`uname -n`# "
118         # kbd_mode -u   # utf-8
119         # export PS1='\[\017\033%G\]'"$PS1"     # \017=std charmap, \033%G=utf-8
120         export PS1='\[\017\]'"$PS1"     # \017=std charmap
121         fi
122 export MINICOM="-m -c on"       # metakeys+color
123 export HISTSIZE=100000
124 export HISTFILESIZE="$HISTSIZE"
125 export CVS_RSH="ssh"
126 grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
127 uname_p="`uname -p`"; [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
128
129 export SOCKS5_SERVER=icsocks.holland.sun.com
130
131 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
132 export LC_COLLATE=C
133
134 function cvsdiff    { cvs diff   "$@" 2>&1|pipebuf -q|             less; }; export -f cvsdiff
135 function cvsdiffi   { cvs diff   "$@" 2>&1|pipebuf -q|grep -v '^?'|less; }; export -f cvsdiffi
136 function cvsupdate  { cvs update "$@" 2>&1|pipebuf -q|             less; }; export -f cvsupdate
137 function cvsupdatei { cvs update "$@" 2>&1|pipebuf -q|grep -v '^?'|less; }; export -f cvsupdatei
138
139 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }; export -f wclines
140 # SunOS does not support "-m"
141 export ULIMITME_OPTS=""
142 for i in "-m 100000" "-d 150000" "-v 200000";do
143         (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
144         done
145 function ulimitme { ulimit $ULIMITME_OPTS; }; export -f ulimitme
146 function grep {(unset grep; ( ulimitme; grep "$@"; ); );}; export -f grep
147 function finame { find . -false `
148         awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@";
149         `; }; export -f finame
150 function mkcd { mkdir -p "$1"; cd "$1"; }; export -f mkcd
151 function pushdmk { mkdir -p "$1"; pushd "$1"; }; export -f pushdmk
152 function rsync {(unset rsync; rsync -v -e ssh --progress --stats --partial --block-size=512 "$@"; );}; export -f rsync
153 function tohex { od -An -txC /tmp/out|tr -d '\n '|tr 'a-f' 'A-F';echo; }; export -f tohex
154 function edall {
155         find -type f|while read -r i;do
156                 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
157                 done
158         }; export -f edall
159 function mi { (
160         set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install;
161         ); };export -f mi
162 function ctags {(unset ctags;
163         if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
164                 find -type f -a '(' -false \
165                                                 -o -name "*.[chC]" \
166                                                 -o -name "*.cc"    \
167                                                 -o -name "*.java"  \
168                                                 -o -name "*.p[lm]" \
169                                                 ')' \
170                                 |ctags --file-tags -L - "$@"
171         fi; );}; export -f ctags
172 function ctagsh { ctags "--c-types=+px"; }; export -f ctagsh
173 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}; export -f cpan
174 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; };export -f exx
175 function revlines { perl -e 'my @r=();push @r,$_ while (<>);print pop @r while @r;'; }; export -f revlines
176
177 ulimit -c 0
178 set +H
179 shopt -s mailwarn
180
181 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
182
183         unset _home_short_dotbashrc     # permit later reinitializations
184 fi      # _home_short_dotbashrc
185
186 true    # Prevent crash in '-e' mode