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";
11 export PATH="$HOME/perl5/bin:$PATH";
13 # "$PS1" for interactive shells detection.
14 if [ -n "$PS1" -a -z "$_home_short_dotbashrc" ];then
15 # We permit later reinitialization by unsetting it.
16 # During our execution we forbid spawning to prevent deadlock by:
18 # . /etc/profile.d/lang.sh
19 # unicode_start iso02.08
20 export _home_short_dotbashrc=true
21 # $TERM gets restored to its 'norc-' state after ~/.bashrc
22 # alias norc='TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;"'
23 function norc { TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;" "$@"; }
25 # Fix $USER and $LOGNAME (not $MAIL) for /etc/passwd line:
26 # root-lace:x:0:0:root for Jan Kratochvil:/home/root-lace:/bin/bash
27 if [ "$UID" -eq 0 -a "$USER" = "root" -a "$HOME" != "${HOME#*/root-}" ];then
32 if [ -f /etc/bashrc ];then source /etc/bashrc;fi
34 _bash_profile_addpath_fini=""
35 function _bash_profile_addpath # <variablename>,<dirpathname>
37 local _varname _varval _varvalold _dirpathname _opt_f _opt_s
40 while getopts fs got;do
42 [fs]) eval "_opt_$got=1" ;;
46 eval "_varname=\"\$$[$OPTIND+0]\""
47 eval "_dirpathname=\"\$$[$OPTIND+1]\""
48 if [ $_opt_f = 0 -a '!' -d "$_dirpathname" ];then return;fi
49 if [ $_opt_s = 1 -o -z "`eval "echo \\${$_varname}"`" ];then
50 eval "$_varname='$_dirpathname'"
52 # We want to prevent duplicates due to .bashrc reentrancy across fork(2)s. It is array!
53 _bash_profile_addpath_fini="$_bash_profile_addpath_fini $_varname"
54 # We want to override any original directories, place dirpathname first!
55 eval "$_varname=\"$_dirpathname:\${$_varname}\""
59 function _bash_profile_addpath_fini
62 for _varname in `echo "$_bash_profile_addpath_fini"|tr ' ' '\n'|sort -u`;do
63 eval "$_varname=\"`eval $(echo "echo \"\\$$_varname\"")|awk -v RS=':' '/[^\n]/{if (!x[$0]++) e=e":"$0;}END{print substr(e,2)}'`\""
65 unset -v _bash_profile_addpath_fini
68 # Use reverse order of preferred directories:
69 # gid(1) dependency on: /opt/sfw/bin
70 # EUID="`id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null || gid -u`"
71 _bash_profile_addpath -f PATH "/sbin"
72 _bash_profile_addpath -f PATH "/usr/sbin"
73 _bash_profile_addpath -f PATH "/bin"
74 _bash_profile_addpath -f PATH "/usr/bin"
75 _bash_profile_addpath PATH "/usr/lib/ccache"
76 _bash_profile_addpath PATH "/usr/lib64/ccache"
77 [ $EUID -eq 0 ] && _bash_profile_addpath -f PATH "/usr/local/sbin"
78 _bash_profile_addpath -f PATH "/usr/local/bin"
79 _bash_profile_addpath -f MANPATH "/usr/X11R6/man"
80 _bash_profile_addpath -f MANPATH "/usr/share/man"
81 _bash_profile_addpath -f MANPATH "/usr/local/man"
82 _bash_profile_addpath -s JAVA_HOME "/usr/java"
83 _bash_profile_addpath -s JAVA_HOME "/usr/local/java"
84 uname_p="`uname -p 2>/dev/null || uname -m`"
85 for family in $HOME;do
86 for arch in $family $family/$uname_p;do
87 # Do not "-f": We use /net !
88 _bash_profile_addpath PATH "$arch/bin"
89 _bash_profile_addpath -s JAVA_HOME "$arch/java"
90 [ $EUID -eq 0 ] && _bash_profile_addpath PATH "$arch/sbin"
91 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib64"
92 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib"
93 _bash_profile_addpath MANPATH "$arch/man"
96 _bash_profile_addpath -f -s CVSROOT ":pserver:pserver:@cvs.jankratochvil.net/cvs" # default
97 [ -n "$JAVA_HOME" ] && _bash_profile_addpath PATH "$JAVA_HOME/bin"
98 _bash_profile_addpath -s CVSROOT "$HOME/pserver/cvs"
99 _bash_profile_addpath -s CVSROOT "$HOME/cvs"
100 _bash_profile_addpath -s ANT_HOME "/usr/local/ant"
102 unset -f _bash_profile_addpath
103 _bash_profile_addpath_fini
104 unset -f _bash_profile_addpath_fini
106 # '2>/dev/null' to prevent: unalias: x: not found
107 # It must be run before `function's below as otherwise it would get embedded.
108 unalias 2>/dev/null cp # -i
109 unalias 2>/dev/null mv # -i
110 unalias 2>/dev/null rm # -i
111 unalias 2>/dev/null df # -h
112 unalias 2>/dev/null du # -h
113 unalias 2>/dev/null ls # --color=auto
114 unalias 2>/dev/null l. # ls -d .* --color=auto
115 unalias 2>/dev/null ll # ls -l --color=auto
116 unalias 2>/dev/null grep # grep --color=auto
118 # Prevent processing of aliases during the parsing of this script file by
121 function grep {(unset grep; ( ulimitme; grep "$@"; ); );}
122 function ls {(unset ls; ( ls -bF "$@"; ); );}
123 function l { ls -lbF "$@"; }
124 if which vim &>/dev/null;then
127 echo >&2 "WARNING: No vim(1)."
129 function grepb { grep --binary-files=binary "$@"; }
130 function L { lynx "$@"; }
131 function chown {(unset chown; ( chown --no-dereference "$@"; ); );}
132 function chgrp {(unset chgrp; ( chgrp --no-dereference "$@"; ); );}
133 function hexedit {(unset hexedit; ( hexedit -s "$@"; ); );}
134 function cvs2cl {(unset cvs2cl; ( cvs2cl --window 3600 --separate-header --no-wrap "$@"; ); );}
135 function cvsfiles { cvsutil --files --print "$@"; }
136 function cvsignores { cvsutil --ignores --print "$@"; }
137 function cvsignoresall { cvsutil --ignores --workings --print "$@"; }
138 function cvsignoresrm { cvsutil --ignores --rm "$@"; }
139 function cvsignoresrmall { cvsutil --ignores --workings --rm "$@"; }
140 function cvsignoresallrm { cvsutil --ignores --workings --rm "$@"; }
141 function svnignoresall { svn status |sed -n "s/^[?] //p" "$@"; }
142 function svnignoresallrm { svn status |sed -n "s/^[?] //p"|tr "\n" "\0"|xargs -0 rm -rf "$@"; }
143 function ignores { find -name "*.orig" -o -name ".#*" -o -name "*~" "$@"; }
144 function ignoresrm { ignores "$@" | xargs rm -f; }
145 function ignoresall { ignores -o -name "*.rej" "$@"; }
146 function ignoresallrm { ignoresall "$@" | xargs rm -f; }
147 function disass { objdump -D --target=binary --architecture=i386:x86-64 "$@"; }
148 function disass32 { objdump -D --target=binary --architecture=i386 "$@"; }
149 function cal {(unset cal; ( cal -m "$@"; ); );}
150 function vncreadonly { vncviewer -FullColor -Shared -ViewOnly "$@"; }
151 function diff {(unset diff; ( diff -dup "$@"; ); );}
152 $(: MAKEFLAGS= - "make install" does not expect -j and .spec files do not force -j1.)
153 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; }
154 function gdbn { gdb -nx --command=~/.gdbinit "$@"; }
155 function hd { od -Ax -tx1; }
156 function wget {(unset wget; ( wget --no-check-certificate "$@"; ); );}
160 # '2>/dev/null' to prevent: TMOUT: readonly variable
161 [ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null
163 [ -x /bin/less ] && export PAGER='/bin/less -MMh5cis'
165 export PERL_LOCAL_LIB_ROOT="$HOME/perl5";
166 export PERL_MB_OPT="--install_base $HOME/perl5";
167 export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5";
169 for file in $HOME/.bookmarks.html;do
170 export WWW_HOME="file://$HOME/"
171 [ -r $file ] && export WWW_HOME="file://$file"
173 export GREP_OPTIONS="--binary-files=without-match --directories=skip"
174 if echo x|GREP_OPTIONS="--exclude=y" grep -q x 2>/dev/null;then
175 export GREP_OPTIONS="$GREP_OPTIONS --exclude=tags --exclude=TAGS --exclude=ChangeLog* --exclude=*.svn-base --exclude=*~"
176 # FIXME: grep(1) ignores subdirectories for --exclude.
177 #export GREP_OPTIONS="$GREP_OPTIONS --exclude=testsuite --exclude=.pc --exclude=.svn --exclude=CVS --exclude=po"
179 if [ -n "$PS1" ];then # set only in interactive sessions
180 if [ ! -f /MOCK ];then
181 export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
183 export PS1='[bash]${LOGNAME}@MOCK-'"`cat /MOCK`"':${PWD}# '
185 export PS1='\[\017\]'"$PS1" # \017=std charmap
186 export PS1='\[\033%G\]'"$PS1" # \033%G=utf-8
187 # Do not: kbd_mode -u # utf-8
188 # as it breaks keyboard state in X and it is not permitted for non-root.
190 export MINICOM="-m -c on" # metakeys+color
191 export HISTSIZE=100000
192 export HISTFILESIZE="$HISTSIZE"
193 export GDBHISTFILE="$HOME/.gdb_history"
195 export TZ=":/usr/share/zoneinfo/Europe/Prague"
196 #export TZ=":/usr/share/zoneinfo/Canada/Eastern"
197 export PYTHONUNBUFFERED=1
199 cpus="`getconf _NPROCESSORS_ONLN`"
200 if [ -n "$cpus" ];then
201 MAKEFLAGS="$MAKEFLAGS -j$[$cpus*3/2]"
204 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
205 # as Sun workaround as Debian misses: /etc/termcap
207 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
208 if grep 2>/dev/null -q '^..............:0C38 00000000:0000 0A ' /proc/net/tcp \
209 || grep 2>/dev/null -q '^....: 00000000000000000000000000000000:0C38 00000000000000000000000000000000:0000 0A ' /proc/net/tcp6 \
211 export http_proxy=http://127.0.0.1:3128/
212 export https_proxy=http://127.0.0.1:3128/
213 export ftp_proxy=http://127.0.0.1:3128/
216 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
217 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
218 [ -r "$_selfabs" ] || unset _selfabs
219 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
222 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
223 export LANG=en_US.UTF-8
224 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
226 # Do not: # Prevent: perl: warning: Setting locale failed.
227 # # due to LC_COLLATE=C and LC_ALL=(unset)
229 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
230 # Re: [Bug-readline] Readline 6.0 patch 004 trapped signal echoed to conso
231 # http://lists.gnu.org/archive/html/bug-readline/2009-09/msg00006.html
232 # 2>/dev/null for possible: stty: standard input: Inappropriate ioctl for device
233 stty -echoctl 2>/dev/null
235 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }
236 # SunOS does not support "-m"
237 export ULIMITME_OPTS=""
238 for i in "-m 100000" "-d 150000" "-v 200000";do
239 (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
241 # Prevent: ulimit: -m 100000 -d 150000 -v 200000: invalid number
242 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
243 function ulimitme { IFS=" " eval "ulimit $ULIMITME_OPTS"; }
244 function finame { find . -false `
245 awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@"
247 function mkcd { mkdir -p "$1"; cd "$1"; }
248 function pushdmk { mkdir -p "$1"; pushd "$1"; }
249 function rsync {(unset rsync; n rsync -a -v -e ssh --progress --stats --inplace --rsync-path='nice -n20 ionice -c3 rsync' "$@"; );}
250 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }
252 find -type f|while read -r i;do
253 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
257 set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install
259 function ctags {(unset ctags
260 if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
261 find -name testsuite -prune -o -name gdbserver -prune -o -name .pc -prune -o -name .svn -prune -o \
262 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
263 -o -name "*.[chCy]" \
273 |ctags --file-tags -L - --langmap=Tcl:+.exp "$@"
275 function ctagsh { ctags "--c-types=+px"; }
276 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}
277 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; }
278 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
279 |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
280 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
281 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}
282 function diffc { diff -dup "$@"|grep -v '^\(Only in \|Binary files\)'; }
283 function diffi { diffc -X ~/.diffi.list "$@" | diffdecvs; }
284 function cvs {(unset cvs
285 local _opts _opts_d _now _line _o
287 if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
288 if grep -iw '\(cvs.fedoraproject.org\):/cvs/pkgs' CVS/Root &>/dev/null;then _opts_d="";fi
289 if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
297 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
298 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
299 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
302 cvs $_line $_opts "$@"
304 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }
305 # `-u' limits the search to $UID.
308 if [ "$1" = "-u" ];then
310 local r="$(pidof "$@")"
314 if grep -q "$(echo -e "^Uid:\t$UID\t")" "/proc/$p/status";then
324 function sumlog { find "$@" ! -name config.log -name "*.log" -o -name "*.sum"; }
325 function sourcewarecvscheckout {(set -ex
328 (set +x;cvs -z3 -d :pserver:anoncvs:@sourceware.org:/cvs/src checkout $1)
332 #(set +x;cvsignoresall)
335 function gdbgitclone { git clone git://sourceware.org/git/gdb.git gdb-git; }
336 function binutilsgitclone { git clone git://sourceware.org/git/binutils.git binutils-git; }
337 function archergitclone { git clone git://sourceware.org/git/archer.git archer-git; }
338 function gdbcvscheckout { sourcewarecvscheckout gdb; }
339 function binutilscvscheckout { sourcewarecvscheckout binutils; }
340 function uri_escape { perl -MURI::Escape -le '$_=<>;chomp;print uri_escape $_;'; };
341 function uri_unescape { perl -MURI::Escape -le '$_=<>;chomp;print uri_unescape $_;'; };
342 # It cannot be a function - unset does not work for it.
343 alias youtube-dl='youtube-dl --format 38/37/45/22/44/35/34/18/6/5/17/13'
344 alias fetchmail='n fetchmail'
348 echo >&2 "rpmsrclist gcc-4.3.2-7 [4.4.0-0.25 [-|http://kojipkgs.fedoraproject.org/packages/gcc/4.4.0/0.25/]]"
350 rpm -q --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}\n' -a \
351 | grep "^$1.src.rpm " | sed 's/^[^ ]* //' \
353 if [ -z "$2" ]; then \
356 sed "s/-$(echo "$1"|sed 's/^.*-\([^-]*-[^-]*\)$/\1/')/-$2/"
359 if [ -z "$3" ]; then \
362 if [ "$3" != - ]; then
363 sed "s#.*#$3&.rpm#"; \
365 base="$(echo "$1"|sed 's/^\(.*\)-[^-]*-[^-]*$/\1/')"; \
366 sed "s#^.*-\([^-]*\)-\([^-]*\)\.\([^.]*\)\$#http://kojipkgs.fedoraproject.org/packages/$base/\1/\2/\3/&.rpm#"; \
372 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 "$@";);}
373 function yumupdate {(ulimit -v unlimited;yum makecache;yum -y --skip-broken update "$@";);}
374 function gitcommit { git commit -a -m .; }
375 function gpg {(unset gpg; http_proxy= all_proxy= HTTP_PROXY= ALL_PROXY= gpg "$@"; );}
383 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
386 for key in $HOME/.ssh/id_dsa;do
391 [ -r "$key" ] || continue
392 # Do not: [ -n "$SSH_TTY" ] && continue
393 # as we may want foreign SSH keys too.
395 agenteval=/tmp/.$USER.ssh-agent.eval
396 if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
397 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
398 # ">/dev/null" to prevent: echo Agent pid 31074
399 source $agenteval >/dev/null
400 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
402 (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
403 # ">/dev/null" to prevent: echo Agent pid 31074
404 source $agenteval >/dev/null
406 rm -f $agenteval.lock
409 # Prevent gdm(8) lockups on non-interactive consoles.
411 (ssh-add -l|grep -qw "$key") && continue
412 if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
413 echo >&2 -n "Locking: $agenteval.input.lock ... "
414 lockfile -1 -r -1 $agenteval.input.lock
417 # Recheck identity existence after the lock acquire
418 if ssh-add -l|grep -qw "$key";then
419 echo >&2 "Identity $key already appended in the meantime."
421 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
422 ssh-add "$key" 2>/dev/null
424 rm -f $agenteval.input.lock
425 echo >&2 "$agenteval.input.lock unlocked."
429 unset _home_short_dotbashrc # permit later reinitializations
430 fi # _home_short_dotbashrc
432 true # Prevent crash in '-e' mode