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