1 # -*- mode: sh; coding: utf-8 -*-
6 if [ -z "$__mdw_bashrc" ]; then
10 [ -z "$__mdw_profile" -a -r $HOME/.bash_profile ] && . $HOME/.bash_profile
11 [ -r /etc/bashrc ] && . /etc/bashrc
13 # --- First of all, set up the prompt string ---
17 if [ "$TERM" = "dumb" ]; then
18 if (( EUID == 0 )); then PS1="# "; else PS1="\$ "; fi
24 linux*|screen*|xterm*|vt100*)
25 bold='\[
\e[1m\]' unbold='\[
\e[m\]' nl='\[
\r\]' ;;
27 bold='' unbold='' nl='' ;;
30 if (( EUID == 0 )); then
31 left=`echo « | iconv -f utf8 -t //translit`
32 right=`echo » | iconv -f utf8 -t //translit`
36 u="" left="[" right="]"
39 u="\\u@" left="{" right="}"
42 if [ "$__mdw_tty" = "`tty`" ]; then
45 export __mdw_tty="`tty`"
49 if [ -z "$SSH_CLIENT" ] &&
50 [ "$__mdw_sechost" != "`hostname`" ]
55 PS1="$nl$bold$left$sec_l$u\\h$sec_r \\w$right$unbold"
56 PS2="$PS1 $bold>$unbold "
61 # --- Little preferences ---
71 shopt -s expand_aliases
78 shopt -s interactive_comments
84 shopt -u shift_verbose
87 # --- Set the CDPATH ---
89 # CDPATH=~/src:/usr/src:/usr/lib:/usr/share
92 # while (( i > 0 )); do
93 # CDPATH=$CDPATH:$dots
99 # --- Some colour `ls' support ---
101 [ "${TMPDIR+yes}" ] || eval `tmpdir -b`
102 if [ -x /usr/bin/dircolors -o -x /usr/local/bin/dircolors ] &&
103 [ "$TERM" != "dumb" ]; then
104 eval `dircolors -b ~/.dircolors`
111 command ls $LS_OPTIONS ${LS_COLORS+--color=auto} "$@"
117 # --- Set up some simple aliases ---
120 alias which="command -v"
121 alias ssync="rsync -e ssh"
122 alias rootly=$__MDW_ROOTLY
124 alias re="rootly $EDITOR"
125 alias pstree="pstree -hl"
126 alias cdtmp='cd ${TMPDIR-/tmp}'
127 alias pushtmp='pushd ${TMPDIR-/tmp}'
129 alias svn="svnwrap svn"
132 [ -r /etc/bash_completion ] && . /etc/bash_completion
133 [ -r $HOME/.bash_completion ] && . $HOME/.bash_completion
135 # --- Make `xt' start an xterm, maybe logging into a remote host ---
140 local remote=${1#@} title
142 if [ $# -gt 0 ]; then
143 title="xterm [$remote] $1"
145 title="xterm [$remote]"
147 (xterm -title "$title" -e ssh $remote "$@" &)
155 # --- Turning on and off core dumps ---
160 ulimit -Sc `ulimit -Hc`
168 0) echo "Core dumps disabled" ;;
169 unlimited) echo "Core dumps enabled" ;;
170 *) echo "Core dump limit is $l blocks" ;;
174 echo >&2 "usage: core [yn]"
180 # --- Turning on and off path hacks ---
183 local pathvar export dir val
185 1) pathvar=PATH dir=$1 export="export PATH";;
186 2) pathvar=$1 dir=$2 export=:;;
187 *) echo >&2 "Usage: $0 [VAR] DIR";;
189 eval "val=\$$pathvar"
194 eval "$pathvar=\$val"
199 local pathvar export dir val
201 1) pathvar=PATH dir=$1 export="export PATH";;
202 2) pathvar=$1 dir=$2 export=:;;
203 *) echo >&2 "Usage: $0 [VAR] DIR";;
205 eval "val=\$$pathvar"
208 :"$dir":*) val=${val#$dir:} ;;
209 *:"$dir":) val=${val%:$dir} ;;
210 *:"$dir":*) val=${val/:$dir:/:} ;;
212 eval "$pathvar=\$val"
217 if [ $# -eq 0 ]; then
222 echo ${e#$HOME/bin/hacks/}
230 while [ $# -gt 0 ]; do
249 dir=$HOME/bin/hacks/$hack
251 echo "$0: path hack $hack not found"
254 case "$arg,$force,:$PATH:" in
256 path-remove path "$dir"
259 path-remove path "$dir"
270 if [ $# -eq 0 ]; then
278 # --- Fix `man' under Slowaris ---
288 case "$arg" in [0-9]*) man[i+=1]="-s" ;; esac
291 command man "${man[@]}"
296 # --- For `root' use -- some simple molly-guards ---
298 if (( UID == 0 )); then
299 alias rm='rm -i' cp='cp -i' mv='mv -i'
303 [ -f "$HOME/.bashrc-local" ] && . "$HOME/.bashrc-local"