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