PS1: prepared for utf-8 system charset
[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 if [ -n "$PS1" ];then   # set only in interactive sessions
80         # kbd_mode -u   # utf-8
81         # export PS1='\[\017\033%G\]'"$PS1"     # \017=std charmap, \033%G=utf-8
82         export PS1='\[\017\]'"$PS1"     # \017=std charmap
83         fi
84 export MINICOM="-m -c on"       # metakeys+color
85 export HISTSIZE=100000
86 export HISTFILESIZE="$HISTSIZE"
87 export CVS_RSH="ssh"
88
89 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
90 export LC_COLLATE=C
91
92 function cvsdiff    { cvs diff   "$@" 2>&1|pipebuf -q|             less; }; export -f cvsdiff
93 function cvsdiffi   { cvs diff   "$@" 2>&1|pipebuf -q|grep -v '^?'|less; }; export -f cvsdiffi
94 function cvsupdate  { cvs update "$@" 2>&1|pipebuf -q|             less; }; export -f cvsupdate
95 function cvsupdatei { cvs update "$@" 2>&1|pipebuf -q|grep -v '^?'|less; }; export -f cvsupdatei
96
97 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }; export -f wclines
98 function ulimitme { ulimit -m 100000 -d 150000 -v 200000; }; export -f ulimitme
99 function grep {(unset grep; ( ulimitme; grep "$@"; ); );}; export -f grep
100 function finame { find . -false `
101         awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@";
102         `; }; export -f finame
103 function mkcd { mkdir -p "$1"; cd "$1"; }; export -f mkcd
104 function pushdmk { mkdir -p "$1"; pushd "$1"; }; export -f pushdmk
105 function rsync {(unset rsync; rsync -v -e ssh --progress --stats --partial --block-size=512 "$@"; );}; export -f rsync
106 function tohex { od -An -txC /tmp/out|tr -d '\n '|tr 'a-f' 'A-F';echo; }; export -f tohex
107 function edall {
108         find -type f|while read -r i;do
109                 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
110                 done
111         }; export -f edall
112 function mi { (
113         set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install;
114         ); };export -f mi
115 function ctags {(unset ctags;
116         if [ $# != 0 ];then ctags "$@";else
117                 find -type f -a '(' -name "*.[chC]" -o -name "*.cc" -o -name "*.java" -o -name "*.p[lm]" ')'|ctags --file-tags -L -
118         fi; );}; export -f ctags
119 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}; export -f cpan
120 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; };export -f exx
121
122 ulimit -c 0
123 set +H
124 shopt -s mailwarn
125
126 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
127
128         unset _home_short_dotbashrc     # permit later reinitializations
129 fi      # _home_short_dotbashrc