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