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
10 export PERL5LIB="$HOME/perl5/lib/perl5/`uname -m`-linux-thread-multi:$HOME/perl5/lib/perl5";
12 # "$PS1" for interactive shells detection.
13 if [ -n "$PS1" -a -z "$_home_short_dotbashrc" ];then
14 # We permit later reinitialization by unsetting it.
15 # During our execution we forbid spawning to prevent deadlock by:
17 # . /etc/profile.d/lang.sh
18 # unicode_start iso02.08
19 export _home_short_dotbashrc=true
20 # $TERM gets restored to its 'norc-' state after ~/.bashrc
21 # alias norc='TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;"'
22 function norc { TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;" "$@"; }
24 # Fix $USER and $LOGNAME (not $MAIL) for /etc/passwd line:
25 # root-lace:x:0:0:root for Jan Kratochvil:/home/root-lace:/bin/bash
26 if [ "$UID" -eq 0 -a "$USER" = "root" -a "$HOME" != "${HOME#*/root-}" ];then
31 if [ -f /etc/bashrc ];then source /etc/bashrc;fi
33 _bash_profile_addpath_fini=""
34 function _bash_profile_addpath # <variablename>,<dirpathname>
36 local _varname _varval _varvalold _dirpathname _opt_f _opt_s
39 while getopts fs got;do
41 [fs]) eval "_opt_$got=1" ;;
45 eval "_varname=\"\$$[$OPTIND+0]\""
46 eval "_dirpathname=\"\$$[$OPTIND+1]\""
47 if [ $_opt_f = 0 -a '!' -d "$_dirpathname" ];then return;fi
48 if [ $_opt_s = 1 -o -z "`eval "echo \\${$_varname}"`" ];then
49 eval "$_varname='$_dirpathname'"
51 # We want to prevent duplicates due to .bashrc reentrancy across fork(2)s. It is array!
52 _bash_profile_addpath_fini="$_bash_profile_addpath_fini $_varname"
53 # We want to override any original directories, place dirpathname first!
54 eval "$_varname=\"$_dirpathname:\${$_varname}\""
58 function _bash_profile_addpath_fini
61 for _varname in `echo "$_bash_profile_addpath_fini"|tr ' ' '\n'|sort -u`;do
62 eval "$_varname=\"`eval $(echo "echo \"\\$$_varname\"")|awk -v RS=':' '/[^\n]/{if (!x[$0]++) e=e":"$0;}END{print substr(e,2)}'`\""
64 unset -v _bash_profile_addpath_fini
67 # Use reverse order of preferred directories:
68 # gid(1) dependency on: /opt/sfw/bin
69 # EUID="`id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null || gid -u`"
70 _bash_profile_addpath -f PATH "/sbin"
71 _bash_profile_addpath -f PATH "/usr/sbin"
72 _bash_profile_addpath -f PATH "/bin"
73 _bash_profile_addpath -f PATH "/usr/bin"
74 _bash_profile_addpath PATH "/usr/lib/ccache"
75 _bash_profile_addpath PATH "/usr/lib64/ccache"
76 [ $EUID -eq 0 ] && _bash_profile_addpath -f PATH "/usr/local/sbin"
77 _bash_profile_addpath -f PATH "/usr/local/bin"
78 _bash_profile_addpath -f MANPATH "/usr/X11R6/man"
79 _bash_profile_addpath -f MANPATH "/usr/share/man"
80 _bash_profile_addpath -f MANPATH "/usr/local/man"
81 _bash_profile_addpath -s JAVA_HOME "/usr/java"
82 _bash_profile_addpath -s JAVA_HOME "/usr/local/java"
83 uname_p="`uname -p 2>/dev/null || uname -m`"
84 for family in $HOME;do
85 for arch in $family $family/$uname_p;do
86 # Do not "-f": We use /net !
87 _bash_profile_addpath PATH "$arch/bin"
88 _bash_profile_addpath -s JAVA_HOME "$arch/java"
89 [ $EUID -eq 0 ] && _bash_profile_addpath PATH "$arch/sbin"
90 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib64"
91 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib"
92 _bash_profile_addpath MANPATH "$arch/man"
95 _bash_profile_addpath -f -s CVSROOT ":pserver:pserver:@cvs.jankratochvil.net/cvs" # default
96 [ -n "$JAVA_HOME" ] && _bash_profile_addpath PATH "$JAVA_HOME/bin"
97 _bash_profile_addpath -s CVSROOT "$HOME/pserver/cvs"
98 _bash_profile_addpath -s CVSROOT "$HOME/cvs"
99 _bash_profile_addpath -s ANT_HOME "/usr/local/ant"
101 unset -f _bash_profile_addpath
102 _bash_profile_addpath_fini
103 unset -f _bash_profile_addpath_fini
105 # '2>/dev/null' to prevent: unalias: x: not found
106 # It must be run before `function's below as otherwise it would get embedded.
107 unalias 2>/dev/null cp # -i
108 unalias 2>/dev/null mv # -i
109 unalias 2>/dev/null rm # -i
110 unalias 2>/dev/null df # -h
111 unalias 2>/dev/null du # -h
112 unalias 2>/dev/null ls # --color=auto
113 unalias 2>/dev/null l. # ls -d .* --color=auto
114 unalias 2>/dev/null ll # ls -l --color=auto
115 unalias 2>/dev/null grep # grep --color=auto
117 # Prevent processing of aliases during the parsing of this script file by
120 function grep {(unset grep; ( ulimitme; grep "$@"; ); );}
121 function ls {(unset ls; ( ls -bF "$@"; ); );}
122 function l { ls -lbF "$@"; }
123 if which vim &>/dev/null;then
126 echo >&2 "WARNING: No vim(1)."
128 function grepb { grep --binary-files=binary "$@"; }
129 function L { lynx "$@"; }
130 function chown {(unset chown; ( chown --no-dereference "$@"; ); );}
131 function chgrp {(unset chgrp; ( chgrp --no-dereference "$@"; ); );}
132 function hexedit {(unset hexedit; ( hexedit -s "$@"; ); );}
133 function cvs2cl {(unset cvs2cl; ( cvs2cl --window 3600 --separate-header --no-wrap "$@"; ); );}
134 function cvsfiles { cvsutil --files --print "$@"; }
135 function cvsignores { cvsutil --ignores --print "$@"; }
136 function cvsignoresall { cvsutil --ignores --workings --print "$@"; }
137 function cvsignoresrm { cvsutil --ignores --rm "$@"; }
138 function cvsignoresrmall { cvsutil --ignores --workings --rm "$@"; }
139 function cvsignoresallrm { cvsutil --ignores --workings --rm "$@"; }
140 function svnignoresall { svn status |sed -n "s/^[?] //p" "$@"; }
141 function svnignoresallrm { svn status |sed -n "s/^[?] //p"|tr "\n" "\0"|xargs -0 rm -rf "$@"; }
142 function ignores { find -name "*.orig" -o -name ".#*" -o -name "*~" "$@"; }
143 function ignoresrm { ignores "$@" | xargs rm -f; }
144 function ignoresall { ignores -o -name "*.rej" "$@"; }
145 function ignoresallrm { ignoresall "$@" | xargs rm -f; }
146 function disass { objdump -D --target=binary --architecture=i386:x86-64 "$@"; }
147 function disass32 { objdump -D --target=binary --architecture=i386 "$@"; }
148 function cal {(unset cal; ( cal -m "$@"; ); );}
149 function vncreadonly { vncviewer -FullColor -Shared -ViewOnly "$@"; }
150 function diff {(unset diff; ( diff -dup "$@"; ); );}
151 $(: MAKEFLAGS= - "make install" does not expect -j and .spec files do not force -j1.)
152 function rpmbuildlocal { MAKEFLAGS= n rpmbuild --define "_topdir $PWD" --define "_builddir $PWD" --define "_rpmdir $PWD" --define "_sourcedir $PWD" --define "_specdir $PWD" --define "_srcrpmdir $PWD" --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" "$@"; rmdir &>/dev/null BUILDROOT; }
153 function gdbn { gdb -nx --command=~/.gdbinit "$@"; }
154 function hd { od -Ax -tx1; }
155 function wget {(unset wget; ( wget --no-check-certificate "$@"; ); );}
156 function ucwkbd { setxkbmap -layout us,cz -variant ,ucw -option grp:caps_switch; }
159 unset command_not_found_handle
160 shopt -u progcomp # Disable 'bash-completion' rpm
162 # '2>/dev/null' to prevent: TMOUT: readonly variable
163 [ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null
165 #broken: [ -x /bin/less ] && export PAGER='/bin/less -rMMh5cis'
167 export PERL_LOCAL_LIB_ROOT="$HOME/perl5";
168 export PERL_MB_OPT="--install_base $HOME/perl5";
169 export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5";
170 # Sometimes needed in non-interactive .bashrc.
171 # Unconditionally it would break quilt.
172 export PATH="$HOME/perl5/bin:$PATH";
174 for file in $HOME/.bookmarks.html;do
175 export WWW_HOME="file://$HOME/"
176 [ -r $file ] && export WWW_HOME="file://$file"
178 if echo x|grep --exclude=y -q x 2>/dev/null;then
179 alias grep='grep --exclude=tags --exclude=TAGS --exclude=ChangeLog* --exclude=*.svn-base --exclude=*~'
180 # FIXME: grep(1) ignores subdirectories for --exclude.
181 # --exclude=testsuite --exclude=.pc --exclude=.svn --exclude=CVS --exclude=po
183 if [ -n "$PS1" ];then # set only in interactive sessions
184 if [ ! -f /MOCK ];then
185 export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
187 export PS1='[bash]${LOGNAME}@MOCK-'"`cat /MOCK`"':${PWD}# '
189 export PS1='\[\017\]'"$PS1" # \017=std charmap
190 export PS1='\[\033%G\]'"$PS1" # \033%G=utf-8
191 # Do not: kbd_mode -u # utf-8
192 # as it breaks keyboard state in X and it is not permitted for non-root.
194 export MINICOM="-m -c on" # metakeys+color
195 export HISTSIZE=100000
196 export HISTFILESIZE="$HISTSIZE"
197 export GDBHISTFILE="$HOME/.gdb_history"
199 export TZ=":/usr/share/zoneinfo/Europe/Prague"
200 #export TZ=":/usr/share/zoneinfo/Canada/Eastern"
201 export PYTHONUNBUFFERED=1
203 cpus="`getconf _NPROCESSORS_ONLN`"
204 if [ -n "$cpus" ];then
205 MAKEFLAGS="$MAKEFLAGS -j$[$cpus*3/2]"
208 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
209 # as Sun workaround as Debian misses: /etc/termcap
211 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
212 if grep 2>/dev/null -q '^..............:0C38 00000000:0000 0A ' /proc/net/tcp \
213 || grep 2>/dev/null -q '^....: 00000000000000000000000000000000:0C38 00000000000000000000000000000000:0000 0A ' /proc/net/tcp6 \
215 export http_proxy=http://127.0.0.1:3128/
216 export https_proxy=http://127.0.0.1:3128/
217 export ftp_proxy=http://127.0.0.1:3128/
220 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
221 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
222 [ -r "$_selfabs" ] || unset _selfabs
223 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
226 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
227 export LANG=en_US.UTF-8
228 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
230 # Do not: # Prevent: perl: warning: Setting locale failed.
231 # # due to LC_COLLATE=C and LC_ALL=(unset)
233 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
234 # Re: [Bug-readline] Readline 6.0 patch 004 trapped signal echoed to conso
235 # http://lists.gnu.org/archive/html/bug-readline/2009-09/msg00006.html
236 # 2>/dev/null for possible: stty: standard input: Inappropriate ioctl for device
237 stty -echoctl 2>/dev/null
238 export GIT_MERGE_AUTOEDIT=no
240 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }
241 # SunOS does not support "-m"
242 export ULIMITME_OPTS=""
243 for i in "-m 100000" "-d 150000" "-v 200000";do
244 (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
246 # Prevent: ulimit: -m 100000 -d 150000 -v 200000: invalid number
247 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
248 function ulimitme { IFS=" " eval "ulimit $ULIMITME_OPTS"; }
249 function finame { find . -false `
250 awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@"
252 function mkcd { mkdir -p "$1"; cd "$1"; }
253 function pushdmk { mkdir -p "$1"; pushd "$1"; }
254 function rsync {(unset rsync; n rsync -c -a -v -e ssh --progress --stats --inplace --rsync-path='nice -n20 ionice -c3 rsync' "$@"; );}
255 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }
257 find -type f|while read -r i;do
258 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
262 set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install
264 function ctags {(unset ctags
265 if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
266 find -name testsuite -prune -o -name gdbserver -prune -o -name .pc -prune -o -name .svn -prune -o \
267 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
268 -o -name "*.[chCy]" \
278 |ctags --file-tags -L - --langmap=Tcl:+.exp "$@"
280 function ctagsh { ctags "--c-types=+px"; }
281 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}
282 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; }
283 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
284 |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
285 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
286 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}
287 function diffc { diff -dup "$@"|grep -v '^\(Only in \|Binary files\)'; }
288 function diffi { diffc -X ~/.diffi.list "$@" | diffdecvs; }
289 function cvs {(unset cvs
290 local _opts _opts_d _now _line _o
292 if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
293 if grep -iw '\(cvs.fedoraproject.org\):/cvs/pkgs' CVS/Root &>/dev/null;then _opts_d="";fi
294 if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
302 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
303 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
304 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
307 cvs $_line $_opts "$@"
309 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }
310 # `-u' limits the search to $UID.
313 if [ "$1" = "-u" ];then
315 local r="$(pidof "$@")"
319 if grep -q "$(echo -e "^Uid:\t$UID\t")" "/proc/$p/status";then
329 function sumlog { find "$@" ! -name config.log -name "*.log" -o -name "*.sum"; }
330 function sourcewarecvscheckout {(set -ex
333 (set +x;cvs -z3 -d :pserver:anoncvs:@sourceware.org:/cvs/src checkout $1)
337 #(set +x;cvsignoresall)
340 function gdbgitclone { git clone git://sourceware.org/git/binutils-gdb.git gdb-git; }
341 function archergitclone { git clone git://sourceware.org/git/archer.git archer-git; }
342 function gdbcvscheckout { sourcewarecvscheckout gdb; }
343 function binutilscvscheckout { sourcewarecvscheckout binutils; }
344 function uri_escape { perl -MURI::Escape -le '$_=<>;chomp;print uri_escape $_;'; };
345 function uri_unescape { perl -MURI::Escape -le '$_=<>;chomp;print uri_unescape $_;'; };
346 alias fetchmail='n fetchmail'
350 echo >&2 "rpmsrclist gcc-4.3.2-7 [4.4.0-0.25 [-|http://kojipkgs.fedoraproject.org/packages/gcc/4.4.0/0.25/]]"
352 rpm -q --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}\n' -a \
353 | grep "^$1.src.rpm " | sed 's/^[^ ]* //' \
355 if [ -z "$2" ]; then \
358 sed "s/-$(echo "$1"|sed 's/^.*-\([^-]*-[^-]*\)$/\1/')/-$2/"
361 if [ -z "$3" ]; then \
364 if [ "$3" != - ]; then
365 sed "s#.*#$3&.rpm#"; \
367 base="$(echo "$1"|sed 's/^\(.*\)-[^-]*-[^-]*$/\1/')"; \
368 sed "s#^.*-\([^-]*\)-\([^-]*\)\.\([^.]*\)\$#http://kojipkgs.fedoraproject.org/packages/$base/\1/\2/\3/&.rpm#"; \
374 function valgrind {(set -e;unset valgrind;s=~/.python.valgrind;rm -f $s;cp -p /usr/share/doc/python-devel-2.*/valgrind-python.supp $s;patch $s <$s.patch;perl -i -e 'undef $/;$_=<>;1 while s/^(?:###)?({\n)(?:###)?( *ADDRESS_IN_RANGE.*\n(?:[^}#].*\n)*)###/$1$2/gm;print;' $s;valgrind --num-callers=50 --suppressions=$s "$@";);}
375 function yumupdate {(ulimit -v unlimited;yum makecache;yum -y --skip-broken update "$@";);}
376 function gitcommit { git commit -a -m .; }
377 function gpg {(unset gpg; http_proxy= all_proxy= HTTP_PROXY= ALL_PROXY= gpg "$@"; );}
386 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
389 for key in $HOME/.ssh/id_dsa;do
394 [ -r "$key" ] || continue
395 # Do not: [ -n "$SSH_TTY" ] && continue
396 # as we may want foreign SSH keys too.
398 agenteval=/tmp/.$USER.ssh-agent.eval
399 if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
400 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
401 # ">/dev/null" to prevent: echo Agent pid 31074
402 source $agenteval >/dev/null
403 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
405 (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
406 # ">/dev/null" to prevent: echo Agent pid 31074
407 source $agenteval >/dev/null
409 rm -f $agenteval.lock
412 # Prevent gdm(8) lockups on non-interactive consoles.
414 (ssh-add -l|grep -qw "$key") && continue
415 if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
416 echo >&2 -n "Locking: $agenteval.input.lock ... "
417 lockfile -1 -r -1 $agenteval.input.lock
420 # Recheck identity existence after the lock acquire
421 if ssh-add -l|grep -qw "$key";then
422 echo >&2 "Identity $key already appended in the meantime."
424 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
425 ssh-add "$key" 2>/dev/null
427 rm -f $agenteval.input.lock
428 echo >&2 "$agenteval.input.lock unlocked."
432 unset _home_short_dotbashrc # permit later reinitializations
433 fi # _home_short_dotbashrc
435 true # Prevent crash in '-e' mode