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