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 ---
18 linux*|screen*|xterm*|vt100*|eterm*)
19 bold="\[$(tput bold)\]" unbold="\[$(tput sgr0)\]" nl="\[
\r\]" ;;
21 bold='' unbold='' nl='' ;;
24 if (( EUID == 0 )); then
25 left=`echo « | iconv -f utf8 -t //translit`
26 right=`echo » | iconv -f utf8 -t //translit`
30 u="" left="[" right="]"
33 u="\\u@" left="{" right="}"
36 if [ "$__mdw_tty" = "`tty`" ]; then
39 export __mdw_tty="`tty`"
43 if [ -z "$SSH_CLIENT" ] &&
44 [ "$__mdw_sechost" != "`hostname`" ]
49 PS1="$nl$bold$left$sec_l$u\\h$sec_r \\w$right$unbold"
50 PS2="$PS1 $bold>$unbold "
54 # --- Pagers are less useful within Emacs ---
56 case "$INSIDE_EMACS" in
57 22.*,comint) export PAGER=cat ;;
60 # --- Little preferences ---
70 shopt -s expand_aliases
77 shopt -s interactive_comments
83 shopt -u shift_verbose
86 # --- Set the CDPATH ---
88 # CDPATH=~/src:/usr/src:/usr/lib:/usr/share
91 # while (( i > 0 )); do
92 # CDPATH=$CDPATH:$dots
98 # --- Some colour `ls' support ---
100 [ "${TMPDIR+yes}" ] || eval `tmpdir -b`
101 if [ -x /usr/bin/dircolors -o -x /usr/local/bin/dircolors ]; then
102 eval `dircolors -b ~/.dircolors`
109 command ls $LS_OPTIONS ${LS_COLORS+--color=auto} "$@"
115 # --- Set up some simple aliases ---
118 alias which="command -v"
119 alias ssync="rsync -e ssh"
120 alias rootly=$__MDW_ROOTLY
122 alias re="rootly $EDITOR"
123 alias pstree="pstree -hl"
124 alias cdtmp='cd ${TMPDIR-/tmp}'
125 alias pushtmp='pushd ${TMPDIR-/tmp}'
127 alias svn="svnwrap svn"
130 [ -r /etc/bash_completion ] && . /etc/bash_completion
131 [ -r $HOME/.bash_completion ] && . $HOME/.bash_completion
133 # --- Make `xt' start an xterm, maybe logging into a remote host ---
138 local remote=${1#@} title
140 if [ $# -gt 0 ]; then
141 title="xterm [$remote] $1"
143 title="xterm [$remote]"
145 (xterm -title "$title" -e ssh $remote "$@" &)
153 # --- Turning on and off core dumps ---
158 ulimit -Sc `ulimit -Hc`
166 0) echo "Core dumps disabled" ;;
167 unlimited) echo "Core dumps enabled" ;;
168 *) echo "Core dump limit is $l blocks" ;;
172 echo >&2 "usage: core [yn]"
178 # --- Turning on and off path hacks ---
181 local pathvar export dir val
183 1) pathvar=PATH dir=$1 export="export PATH";;
184 2) pathvar=$1 dir=$2 export=:;;
185 *) echo >&2 "Usage: $0 [VAR] DIR";;
187 eval "val=\$$pathvar"
192 eval "$pathvar=\$val"
197 local pathvar export dir val
199 1) pathvar=PATH dir=$1 export="export PATH";;
200 2) pathvar=$1 dir=$2 export=:;;
201 *) echo >&2 "Usage: $0 [VAR] DIR";;
203 eval "val=\$$pathvar"
206 :"$dir":*) val=${val#$dir:} ;;
207 *:"$dir":) val=${val%:$dir} ;;
208 *:"$dir":*) val=${val/:$dir:/:} ;;
210 eval "$pathvar=\$val"
215 if [ $# -eq 0 ]; then
220 echo ${e#$HOME/bin/hacks/}
228 while [ $# -gt 0 ]; do
247 dir=$HOME/bin/hacks/$hack
249 echo "$0: path hack $hack not found"
252 case "$arg,$force,:$PATH:" in
254 path-remove path "$dir"
257 path-remove path "$dir"
268 if [ $# -eq 0 ]; then
276 # --- Fix `man' under Slowaris ---
286 case "$arg" in [0-9]*) man[i+=1]="-s" ;; esac
289 command man "${man[@]}"
294 # --- For `root' use -- some simple molly-guards ---
296 if (( UID == 0 )); then
297 alias rm='rm -i' cp='cp -i' mv='mv -i'
301 [ -f "$HOME/.bashrc-local" ] && . "$HOME/.bashrc-local"