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