Updated php-5.x compatibility ($HTTP_GET_VARS).
[nethome.git] / .bashrc
1 if [ -n "$_home_short_dotbashrc_norc" -o "${TERM#norc-}" != "$TERM" ];then
2         # We could get executed twice:
3         export _home_short_dotbashrc_norc=true
4         # Do not use $TZ as Solaris sshd(8) does not propagate it.
5         # Be aware you must use 'ssh -t' to propagate $TERM otherwise '=dumb'.
6         export TERM="${TERM#norc-}"
7         export _home_short_dotbashrc=true
8 fi
9
10 if [ -z "$_home_short_dotbashrc" ];then
11         _home_short_dotbashrc=true
12         # $TERM gets restored to its 'norc-' state after ~/.bashrc
13         # alias norc='TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;"'
14         function norc { TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;" "$@"; }; export -f norc
15
16 if [ -f /etc/bashrc ];then source /etc/bashrc;fi
17
18 function _bash_profile_addpath  # <variablename>,<dirpathname>
19 {
20         local _varname _dirpathname _opt_f _opt_s
21         _opt_f=0;_opt_s=0
22         unset OPTIND
23         while getopts fs got;do
24                 case "$got" in
25                         [fs]) eval "_opt_$got=1" ;;
26                         *) return 1 ;;
27                         esac
28                 done
29         eval "_varname=\"\$$[$OPTIND+0]\""
30         eval "_dirpathname=\"\$$[$OPTIND+1]\""
31         if [ $_opt_f = 0 -a '!' -d "$_dirpathname" ];then return;fi
32         if [ $_opt_s = 1 -o -z "`eval "echo \\${$_varname}"`" ];then
33                 eval "$_varname='$_dirpathname'"
34         else
35                 # we want to override any original directories, place dirpathname first!
36                 eval "$_varname=\"$_dirpathname:\${$_varname}\""
37         fi
38         export "$_varname"
39 }
40
41 # Use reverse order of preferred directories:
42 # gid(1) dependency on: /opt/sfw/bin
43 # EUID="`id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null || gid -u`"
44 _bash_profile_addpath -f PATH            "/opt/SUNWspro/bin"
45 _bash_profile_addpath -f PATH            "/usr/dist/exe"
46 _bash_profile_addpath -f PATH            "/sbin"
47 _bash_profile_addpath -f PATH            "/usr/sbin"
48 _bash_profile_addpath -f PATH            "/opt/sfw/bin"
49 [ -x $HOME/bin/ProductivityTools-check ] && eval `$HOME/bin/ProductivityTools-check`
50 [ -n "$PATH_PRODUCTIVITY_TOOLS" ] && _bash_profile_addpath -f PATH "$PATH_PRODUCTIVITY_TOOLS"
51 [ $EUID -eq 0 ] && _bash_profile_addpath -f PATH "/usr/local/sbin"
52 _bash_profile_addpath -f PATH            "/usr/local/bin"
53 _bash_profile_addpath -f LD_LIBRARY_PATH "/opt/sfw/lib"
54 _bash_profile_addpath -f MANPATH         "/usr/X11R6/man"
55 _bash_profile_addpath -f MANPATH         "/usr/share/man"
56 _bash_profile_addpath -f MANPATH         "/usr/local/man"
57 _bash_profile_addpath -s JAVA_HOME       "/usr/java"
58 _bash_profile_addpath -s JAVA_HOME       "/usr/local/java"
59 uname_p="`uname -p 2>/dev/null || uname -m`"
60 [ "`uname`" = "SunOS" ] && _bash_profile_addpath -f LD_LIBRARY_PATH "$HOME/Netscape/dist/lib"
61 for family in "/net/jsc-nfs.czech.sun.com/export/jscqa-local" "$HOME";do
62         for arch in "$family" $family/$uname_p;do
63                 # Do not "-f": We use /net !
64                 _bash_profile_addpath PATH            "$arch/bin"
65                 _bash_profile_addpath PATH            "$arch/OpenOffice.org"
66                 _bash_profile_addpath PATH            "$arch/forte4j/extbin"
67                 _bash_profile_addpath -s JAVA_HOME    "$arch/java"
68                 [ $EUID -eq 0 ] && _bash_profile_addpath PATH "$arch/sbin"
69                 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib"
70                 _bash_profile_addpath MANPATH         "$arch/man"
71                 done
72         done
73 _bash_profile_addpath -f -s CVSROOT "short@vellum.cz:/home/short/pserver/cvs"   # default
74 [ -n "$JAVA_HOME" ] && _bash_profile_addpath PATH "$JAVA_HOME/bin"
75 _bash_profile_addpath    -s CVSROOT "$HOME/pserver/cvs"
76 _bash_profile_addpath    -s CVSROOT "$HOME/cvs"
77 _bash_profile_addpath    -s ANT_HOME "/usr/local/ant"
78
79 # /share/perl for Debian
80 # /lib/perl for Debian
81 # /lib/perl5 for Fedora Core
82 mkdir -p $HOME/lib/perl5        # otherwise CPAN will install to "$HOME/lib/site_perl" etc.
83 for _perldir in $(eval "echo {/usr,$HOME}{/lib/perl5,/share/perl,/lib/perl}{,/site_perl}$(
84         for perlvar in version archname;do
85                 echo -n '{,/'
86                 perl -V:"$perlvar"|cut -d "'" -f 2|tr -d '\n'
87                 echo -n '}'
88                 done
89         )");do
90         _bash_profile_addpath -f PERLLIB "$_perldir"
91         done
92 unset _perldir
93
94 unset -f _bash_profile_addpath
95
96 for i in tar ls find cp mv ln md5sum du grep ar chown chmod tail;do
97         # Prevent g$i from system directory overriding customized $i binary
98         which $i 2>/dev/null | grep /net/jsc-nfs.czech.sun.com/export/jscqa-local/ >/dev/null && continue
99         which g$i 2>/dev/null | grep '^/' >/dev/null && alias $i=g$i
100         done
101
102 alias ls='ls -bF'
103 alias l='ls -lbF'
104 alias maple="ssh -t vega.fjfi.cvut.cz maple"
105 #alias cc='cc -I/home/short/include'
106 alias vi='vim'
107 alias grepb='grep --binary-files=binary'
108 alias L='lynx'
109 alias cvs2cl='cvs2cl --window 3600 --separate-header --no-wrap'
110 alias cvsfiles='cvsutil --files --print'
111 alias cvsignores='cvsutil --ignores --print'
112 alias cvsignoresall='cvsutil --ignores --workings --print'
113 alias cvsignoresrm='cvsutil --ignores --rm'
114 alias cvsignoresrmall='cvsutil --ignores --workings --rm'
115 alias cvsignoresallrm='cvsutil --ignores --workings --rm'
116 [ "`uname`" = "SunOS" -a -x $HOME/bin/rpm-by-pkg ] && alias rpm='rpm-by-pkg'
117 alias rpmdb='rpm --define "_dbpath `echo /usr/lib/rpmdb/*/*`"'
118
119 # '2>/dev/null' to prevent: unalias: x: not found
120 unalias 2>/dev/null cp  # -i
121 unalias 2>/dev/null mv  # -i
122 unalias 2>/dev/null rm  # -i
123 unalias 2>/dev/null df  # -h
124 unalias 2>/dev/null du  # -h
125
126 export IGNOREEOF=10
127 # '2>/dev/null' to prevent: TMOUT: readonly variable
128 export TMOUT=900 2>/dev/null
129 export EDITOR='vim'
130 [ -x /bin/less ] && export PAGER='/bin/less -MMh5cis'
131 export PERL_MM_OPT="PERL=$HOME/bin/perlilib"
132 [ "$UID" -ne 0 ] && export PERL_MM_OPT="$PERL_MM_OPT PREFIX=$HOME"
133 for file in $HOME/.bookmarks.html;do
134         export WWW_HOME="file://$HOME/"
135         [ -r $file ] && export WWW_HOME="file://$file"
136         done
137 export GREP_OPTIONS="--binary-files=without-match --directories=skip"
138 if [ -n "$PS1" ];then   # set only in interactive sessions
139         export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
140         export PS1='\[\017\]'"$PS1"     # \017=std charmap
141         export PS1='\[\033%G\]'"$PS1"   # \033%G=utf-8
142         # Do not: kbd_mode -u # utf-8
143         # as it breaks keyboard state in X and it is not permitted for non-root.
144         fi
145 export MINICOM="-m -c on"       # metakeys+color
146 export HISTSIZE=100000
147 export HISTFILESIZE="$HISTSIZE"
148 export CVS_RSH="ssh"
149 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
150 # as Sun workaround as Debian misses: /etc/termcap
151 # expects: $uname_p
152 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
153
154 export SOCKS5_SERVER=icsocks.holland.sun.com
155
156 # Force English.
157 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
158 export LANG=en_US.UTF-8
159 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
160 export LC_COLLATE=C
161 # Do not: # Prevent: perl: warning: Setting locale failed.
162 #         # due to LC_COLLATE=C and LC_ALL=(unset)
163 #         export LC_ALL=C
164 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
165
166 function cvsdiff    { cvs diff   "$@" 2>&1|pipebuf -q|             less; }; export -f cvsdiff
167 function cvsdiffi   { cvs diff   "$@" 2>&1|pipebuf -q|grep -v '^?'|less; }; export -f cvsdiffi
168 function cvsupdate  { cvs update "$@" 2>&1|pipebuf -q|             less; }; export -f cvsupdate
169 function cvsupdatei { cvs update "$@" 2>&1|pipebuf -q|grep -v '^?'|less; }; export -f cvsupdatei
170
171 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }; export -f wclines
172 # SunOS does not support "-m"
173 export ULIMITME_OPTS=""
174 for i in "-m 100000" "-d 150000" "-v 200000";do
175         (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
176         done
177 # Prevent: ulimit:  -m 100000 -d 150000 -v 200000: invalid number
178 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
179 function ulimitme { IFS=" " eval "ulimit $ULIMITME_OPTS"; }; export -f ulimitme
180 function grep {(unset grep; ( ulimitme; grep "$@"; ); );}; export -f grep
181 function finame { find . -false `
182         awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@";
183         `; }; export -f finame
184 function mkcd { mkdir -p "$1"; cd "$1"; }; export -f mkcd
185 function pushdmk { mkdir -p "$1"; pushd "$1"; }; export -f pushdmk
186 function rsync {(unset rsync; rsync -v -e ssh --progress --stats --partial --block-size=512 "$@"; );}; export -f rsync
187 function tohex { od -An -txC /tmp/out|tr -d '\n '|tr 'a-f' 'A-F';echo; }; export -f tohex
188 function edall {
189         find -type f|while read -r i;do
190                 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
191                 done
192         }; export -f edall
193 function mi { (
194         set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install;
195         ); };export -f mi
196 function ctags {(unset ctags;
197         if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
198                 find -type f -a '(' -false \
199                                                 -o -name "*.[chC]" \
200                                                 -o -name "*.cc"    \
201                                                 -o -name "*.java"  \
202                                                 -o -name "*.p[lm]" \
203                                                 ')' \
204                                 |ctags --file-tags -L - "$@"
205         fi; );}; export -f ctags
206 function ctagsh { ctags "--c-types=+px"; }; export -f ctagsh
207 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}; export -f cpan
208 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; };export -f exx
209 function revlines { perl -e 'my @r=();push @r,$_ while (<>);print pop @r while @r;'; }; export -f revlines
210
211 ulimit -c 0
212 set +H
213 shopt -s mailwarn
214 unset OPTIND
215
216 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
217
218         unset _home_short_dotbashrc     # permit later reinitializations
219 fi      # _home_short_dotbashrc
220
221 true    # Prevent crash in '-e' mode