1 # -*- mode: sh; coding: utf-8 -*-
3 # $Id: .bashrc,v 1.6 1996/12/08 20:33:42 mdw Exp $
8 if [ -z "$__mdw_bashrc" ]; then
12 [ -z "$__mdw_profile" -a -r $HOME/.bash_profile ] && . $HOME/.bash_profile
13 [ -r /etc/bashrc ] && . /etc/bashrc
15 # --- First of all, set up the prompt string ---
19 if [ "$TERM" = "dumb" ]; then
20 if (( EUID == 0 )); then PS1="# "; else PS1="\$ "; fi
26 linux*|screen*|xterm*|vt100*)
27 bold='\[
\e[1m\]' unbold='\[
\e[m\]' nl='\[
\r\]' ;;
29 bold='' unbold='' nl='' ;;
32 if (( EUID == 0 )); then
33 left=`echo « | iconv -f utf8 -t //translit`
34 right=`echo » | iconv -f utf8 -t //translit`
38 u="" left="[" right="]"
41 u="\\u@" left="{" right="}"
44 if [ "$__mdw_tty" = "`tty`" ]; then
47 export __mdw_tty="`tty`"
51 if [ -z "$SSH_CLIENT" ] &&
52 [ "$__mdw_sechost" != "`hostname`" ]
57 PS1="$nl$bold$left$sec_l$u\\h$sec_r \\w$right$unbold"
58 PS2="$PS1 $bold>$unbold "
63 # --- Little preferences ---
73 shopt -s expand_aliases
80 shopt -s interactive_comments
86 shopt -u shift_verbose
89 # --- Set the CDPATH ---
91 # CDPATH=~/src:/usr/src:/usr/lib:/usr/share
94 # while (( i > 0 )); do
95 # CDPATH=$CDPATH:$dots
101 # --- Some colour `ls' support ---
103 [ "${TMPDIR+yes}" ] || eval `tmpdir -b`
104 if [ -x /usr/bin/dircolors -o -x /usr/local/bin/dircolors ] &&
105 [ "$TERM" != "dumb" ]; then
106 eval `dircolors -b ~/.dircolors`
113 command ls $LS_OPTIONS ${LS_COLORS+--color=auto} "$@"
119 # --- Set up some simple aliases ---
122 alias which="command -v"
123 alias ssync="rsync -e ssh"
124 alias rootly=$__MDW_ROOTLY
126 alias re="rootly $EDITOR"
127 alias pstree="pstree -hl"
128 alias cdtmp='cd ${TMPDIR-/tmp}'
129 alias pushtmp='pushd ${TMPDIR-/tmp}'
131 alias svn="svnwrap svn"
134 [ -r /etc/bash_completion ] && . /etc/bash_completion
135 [ -r $HOME/.bash_completion ] && . $HOME/.bash_completion
137 # --- Make `xt' start an xterm, maybe logging into a remote host ---
142 local remote=${1#@} title
144 if [ $# -gt 0 ]; then
145 title="xterm [$remote] $1"
147 title="xterm [$remote]"
149 (xterm -title "$title" -e ssh $remote "$@" &)
157 # --- Turning on and off core dumps ---
162 ulimit -Sc `ulimit -Hc`
170 0) echo "Core dumps disabled" ;;
171 unlimited) echo "Core dumps enabled" ;;
172 *) echo "Core dump limit is $l blocks" ;;
176 echo >&2 "usage: core [yn]"
182 # --- Turning on and off path hacks ---
185 local pathvar export dir val
187 1) pathvar=PATH dir=$1 export="export PATH";;
188 2) pathvar=$1 dir=$2 export=:;;
189 *) echo >&2 "Usage: $0 [VAR] DIR";;
191 eval "val=\$$pathvar"
196 eval "$pathvar=\$val"
201 local pathvar export dir val
203 1) pathvar=PATH dir=$1 export="export PATH";;
204 2) pathvar=$1 dir=$2 export=:;;
205 *) echo >&2 "Usage: $0 [VAR] DIR";;
207 eval "val=\$$pathvar"
210 :"$dir":*) val=${val#$dir:} ;;
211 *:"$dir":) val=${val%:$dir} ;;
212 *:"$dir":*) val=${val/:$dir:/:} ;;
214 eval "$pathvar=\$val"
219 if [ $# -eq 0 ]; then
224 echo ${e#$HOME/bin/hacks/}
232 while [ $# -gt 0 ]; do
251 dir=$HOME/bin/hacks/$hack
253 echo "$0: path hack $hack not found"
256 case "$arg,$force,:$PATH:" in
258 path-remove path "$dir"
261 path-remove path "$dir"
272 if [ $# -eq 0 ]; then
280 # --- Fix `man' under Slowaris ---
290 case "$arg" in [0-9]*) man[i+=1]="-s" ;; esac
293 command man "${man[@]}"
298 # --- For `root' use -- some simple molly-guards ---
300 if (( UID == 0 )); then
301 alias rm='rm -i' cp='cp -i' mv='mv -i'
305 [ -f "$HOME/.bashrc-local" ] && . "$HOME/.bashrc-local"