4 if [ -n "$_home_short_dotbashrc_norc" -o "${TERM#norc-}" != "$TERM" ];then
5 # We could get executed twice:
6 export _home_short_dotbashrc_norc=true
7 # Do not use $TZ as Solaris sshd(8) does not propagate it.
8 # Be aware you must use 'ssh -t' to propagate $TERM otherwise '=dumb'.
9 export TERM="${TERM#norc-}"
10 export _home_short_dotbashrc=true
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;" "$@"; }; export -f norc
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 [ $EUID -eq 0 ] && _bash_profile_addpath -f PATH "/usr/local/sbin"
74 _bash_profile_addpath -f PATH "/usr/local/bin"
75 _bash_profile_addpath -f MANPATH "/usr/X11R6/man"
76 _bash_profile_addpath -f MANPATH "/usr/share/man"
77 _bash_profile_addpath -f MANPATH "/usr/local/man"
78 _bash_profile_addpath -s JAVA_HOME "/usr/java"
79 _bash_profile_addpath -s JAVA_HOME "/usr/local/java"
80 uname_p="`uname -p 2>/dev/null || uname -m`"
81 for family in $HOME;do
82 for arch in $family $family/$uname_p;do
83 # Do not "-f": We use /net !
84 _bash_profile_addpath PATH "$arch/bin"
85 _bash_profile_addpath -s JAVA_HOME "$arch/java"
86 [ $EUID -eq 0 ] && _bash_profile_addpath PATH "$arch/sbin"
87 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib64"
88 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib"
89 _bash_profile_addpath MANPATH "$arch/man"
92 _bash_profile_addpath -f -s CVSROOT ":pserver:pserver:@cvs.jankratochvil.net/cvs" # default
93 [ -n "$JAVA_HOME" ] && _bash_profile_addpath PATH "$JAVA_HOME/bin"
94 _bash_profile_addpath -s CVSROOT "$HOME/pserver/cvs"
95 _bash_profile_addpath -s CVSROOT "$HOME/cvs"
96 _bash_profile_addpath -s ANT_HOME "/usr/local/ant"
98 # /share/perl for Debian
99 # /lib/perl for Debian
100 # /lib/perl5 for Fedora Core
101 mkdir -p $HOME/lib{64,}/perl5 # otherwise CPAN will install to "$HOME/lib{64,}/site_perl" etc.
102 _perlpatt="$(perl -MConfig -e 'print "{,/".$Config{$_}."}" for qw(version archname);')"
103 for _perldir in $(eval "echo {/usr,$HOME}{/lib{64,}/perl{,5},/share/perl}{,/site_perl}$_perlpatt");do
104 # $PERL5LIB overrides $PERLLIB and it is being used by: /etc/profile.d/atrpms.*
105 _bash_profile_addpath -f PERL5LIB "$_perldir"
109 unset -f _bash_profile_addpath
110 _bash_profile_addpath_fini
111 unset -f _bash_profile_addpath_fini
113 for i in tar ls find cp mv ln md5sum du grep ar chown chmod tail;do
114 # Prevent g$i from system directory overriding customized $i binary
115 which g$i 2>/dev/null | grep '^/' >/dev/null && alias $i=g$i
120 alias maple="ssh -t vega.fjfi.cvut.cz maple"
121 #alias cc='cc -I/home/short/include'
122 if which vim &>/dev/null;then
125 echo >&2 'WARNING: No vim(1).'
127 alias grepb='grep --binary-files=binary'
129 alias chown='chown --no-dereference'
130 alias chgrp='chgrp --no-dereference'
131 alias hexedit='hexedit -s'
132 alias cvs2cl='cvs2cl --window 3600 --separate-header --no-wrap'
133 alias cvsfiles='cvsutil --files --print'
134 alias cvsignores='cvsutil --ignores --print'
135 alias cvsignoresall='cvsutil --ignores --workings --print'
136 alias cvsignoresrm='cvsutil --ignores --rm'
137 alias cvsignoresrmall='cvsutil --ignores --workings --rm'
138 alias cvsignoresallrm='cvsutil --ignores --workings --rm'
139 alias svnignoresall='svn status |sed -n "s/^[?] //p"'
140 alias svnignoresallrm='svn status |sed -n "s/^[?] //p"|tr "\n" "\0"|xargs -0 rm -rf'
141 alias disass='objdump -D --target=binary --architecture=i386'
143 alias vncreadonly='vncviewer -FullColor -Shared -ViewOnly'
145 alias rpmbuildlocal='nice rpmbuild --define "_topdir $PWD" --define "_builddir $PWD" --define "_rpmdir $PWD" --define "_sourcedir $PWD" --define "_specdir $PWD" --define "_srcrpmdir $PWD"'
146 alias gdbn='gdb -nx --command=~/.gdbinit'
148 # '2>/dev/null' to prevent: unalias: x: not found
149 unalias 2>/dev/null cp # -i
150 unalias 2>/dev/null mv # -i
151 unalias 2>/dev/null rm # -i
152 unalias 2>/dev/null df # -h
153 unalias 2>/dev/null du # -h
156 # '2>/dev/null' to prevent: TMOUT: readonly variable
157 [ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null
159 [ -x /bin/less ] && export PAGER='/bin/less -MMh5cis'
160 export PERL_MM_OPT="PERL=$HOME/bin/perlilib"
161 [ "$UID" -ne 0 ] && export PERL_MM_OPT="$PERL_MM_OPT PREFIX=$HOME"
162 for file in $HOME/.bookmarks.html;do
163 export WWW_HOME="file://$HOME/"
164 [ -r $file ] && export WWW_HOME="file://$file"
166 export GREP_OPTIONS="--binary-files=without-match --directories=skip"
167 if echo x|GREP_OPTIONS="--exclude=y" grep -q x 2>/dev/null;then
168 export GREP_OPTIONS="$GREP_OPTIONS --exclude=tags --exclude=TAGS --exclude=CVS --exclude=ChangeLog*"
169 # FIXME: grep(1) ignores subdirectories for --exclude.
170 #export GREP_OPTIONS="$GREP_OPTIONS --exclude=testsuite --exclude=.pc --exclude=.svn"
172 if [ -n "$PS1" ];then # set only in interactive sessions
173 export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
174 export PS1='\[\017\]'"$PS1" # \017=std charmap
175 export PS1='\[\033%G\]'"$PS1" # \033%G=utf-8
176 # Do not: kbd_mode -u # utf-8
177 # as it breaks keyboard state in X and it is not permitted for non-root.
179 export MINICOM="-m -c on" # metakeys+color
180 export HISTSIZE=100000
181 export HISTFILESIZE="$HISTSIZE"
182 export GDBHISTFILE="$HOME/.gdb_history"
184 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
185 # as Sun workaround as Debian misses: /etc/termcap
187 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
188 if grep 2>/dev/null -q '^..............:0C38 00000000:0000 0A ' /proc/net/tcp;then
189 export http_proxy=http://127.0.0.1:3128/
190 export https_proxy=http://127.0.0.1:3128/
191 export ftp_proxy=http://127.0.0.1:3128/
194 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
195 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
196 [ -r "$_selfabs" ] || unset _selfabs
197 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
200 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
201 export LANG=en_US.UTF-8
202 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
204 # Do not: # Prevent: perl: warning: Setting locale failed.
205 # # due to LC_COLLATE=C and LC_ALL=(unset)
207 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
209 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }; export -f wclines
210 # SunOS does not support "-m"
211 export ULIMITME_OPTS=""
212 for i in "-m 100000" "-d 150000" "-v 200000";do
213 (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
215 # Prevent: ulimit: -m 100000 -d 150000 -v 200000: invalid number
216 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
217 function ulimitme { IFS=" " eval "ulimit $ULIMITME_OPTS"; }; export -f ulimitme
218 function grep {(unset grep; ( ulimitme; grep "$@"; ); );}; export -f grep
219 function finame { find . -false `
220 awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@";
221 `; }; export -f finame
222 function mkcd { mkdir -p "$1"; cd "$1"; }; export -f mkcd
223 function pushdmk { mkdir -p "$1"; pushd "$1"; }; export -f pushdmk
224 function rsync {(unset rsync; nice -n20 rsync -v -e ssh --progress --stats --partial --rsync-path='nice -n20 rsync' "$@"; );}; export -f rsync
225 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }; export -f tohex
227 find -type f|while read -r i;do
228 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
232 set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install;
234 function ctags {(unset ctags;
235 if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
236 find -name testsuite -prune -o -name .pc -prune -o -name .svn -prune -o \
237 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
246 |ctags --file-tags -L - --langmap=Tcl:+.exp "$@"
247 fi; );}; export -f ctags
248 function ctagsh { ctags "--c-types=+px"; }; export -f ctagsh
249 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}; export -f cpan
250 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; };export -f exx
251 function revlines { perl -e 'print reverse <>;'; }; export -f revlines
252 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
253 |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
254 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
255 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}; export -f eog
256 function diffc { diff -u "$@"|grep -v '^\(Only in \|Binary files\)'; }; export -f diffc
257 function diffi { diffc -X ~/.diffi.list "$@"; }; export -f diffi
258 function cvs {(unset cvs;
259 local _opts _opts_d _now _line _o
261 if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
262 if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
270 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
271 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
272 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
275 cvs $_line $_opts "$@"
277 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }; export -f perlrpm
285 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
288 for key in $HOME/.ssh/id_dsa;do
289 [ -r "$key" ] || continue
290 # Do not: [ -n "$SSH_TTY" ] && continue
291 # as we may want foreign SSH keys too.
293 agenteval=/tmp/.$USER.ssh-agent.eval
294 if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
295 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
296 # ">/dev/null" to prevent: echo Agent pid 31074;
297 source $agenteval >/dev/null
298 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
300 (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
301 # ">/dev/null" to prevent: echo Agent pid 31074;
302 source $agenteval >/dev/null
304 rm -f $agenteval.lock
307 # Prevent gdm(8) lockups on non-interactive consoles.
309 (ssh-add -l|grep -qw "$key") && continue
310 if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
311 echo >&2 -n "Locking: $agenteval.input.lock ... "
312 lockfile -1 -r -1 $agenteval.input.lock
315 # Recheck identity existence after the lock acquire
316 if ssh-add -l|grep -qw "$key";then
317 echo >&2 "Identity $key already appended in the meantime."
319 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
320 ssh-add "$key" 2>/dev/null
322 rm -f $agenteval.input.lock
323 echo >&2 "$agenteval.input.lock unlocked."
327 unset _home_short_dotbashrc # permit later reinitializations
328 fi # _home_short_dotbashrc
330 true # Prevent crash in '-e' mode