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
79 shopt -s interactive_comments
85 shopt -u shift_verbose
88 HISTCONTROL=ignorespace:erasedups
90 # --- Set the CDPATH ---
92 # CDPATH=~/src:/usr/src:/usr/lib:/usr/share
95 # while (( i > 0 )); do
96 # CDPATH=$CDPATH:$dots
102 # --- Some colour `ls' support ---
104 [ "${TMPDIR+yes}" ] || eval `tmpdir -b`
105 if [ -x /usr/bin/dircolors -o -x /usr/local/bin/dircolors ]; then
106 eval `dircolors -b ~/.dircolors`
113 command ls $LS_OPTIONS ${LS_COLORS+--color=auto} "$@"
119 # --- Some colour `grep' support ---
121 export GREP_COLORS="mt=01;31:ms=01;31:mc=031;31:fn=36:ln=36:bn=36:se=34"
124 declare grep=$1; shift
126 command $grep ${GREP_COLORS+--color=always} "$@" | mdw-pager
131 alias grep="greplike grep"
132 alias egrep="greplike egrep"
133 alias fgrep="greplike fgrep"
134 alias zgrep="greplike zgrep"
136 # --- Set up some simple aliases ---
139 alias which="command -v"
140 alias ssync="rsync -e ssh"
141 alias rootly=$__MDW_ROOTLY
143 alias re="rootly $EDITOR"
144 alias pstree="pstree -hl"
145 alias cdtmp='cd ${TMPDIR-/tmp}'
146 alias pushtmp='pushd ${TMPDIR-/tmp}'
148 alias svn="svnwrap svn"
151 [ -r /etc/bash_completion ] && . /etc/bash_completion
152 [ -r $HOME/.bash_completion ] && . $HOME/.bash_completion
154 # --- Make `xt' start an xterm, maybe logging into a remote host ---
159 local remote=${1#@} title
161 if [ $# -gt 0 ]; then
162 title="xterm [$remote] $1"
164 title="xterm [$remote]"
166 (xterm -title "$title" -e ssh $remote "$@" &)
174 # --- Turning on and off core dumps ---
179 ulimit -Sc `ulimit -Hc`
187 0) echo "Core dumps disabled" ;;
188 unlimited) echo "Core dumps enabled" ;;
189 *) echo "Core dump limit is $l blocks" ;;
193 echo >&2 "usage: core [yn]"
199 # --- Turning on and off path hacks ---
202 local pathvar export dir val
204 1) pathvar=PATH dir=$1 export="export PATH";;
205 2) pathvar=$1 dir=$2 export=:;;
206 *) echo >&2 "Usage: $0 [VAR] DIR";;
208 eval "val=\$$pathvar"
213 eval "$pathvar=\$val"
218 local pathvar export dir val
220 1) pathvar=PATH dir=$1 export="export PATH";;
221 2) pathvar=$1 dir=$2 export=:;;
222 *) echo >&2 "Usage: $0 [VAR] DIR";;
224 eval "val=\$$pathvar"
227 :"$dir":*) val=${val#$dir:} ;;
228 *:"$dir":) val=${val%:$dir} ;;
229 *:"$dir":*) val=${val/:$dir:/:} ;;
231 eval "$pathvar=\$val"
236 if [ $# -eq 0 ]; then
241 echo ${e#$HOME/bin/hacks/}
249 while [ $# -gt 0 ]; do
268 dir=$HOME/bin/hacks/$hack
270 echo "$0: path hack $hack not found"
273 case "$arg,$force,:$PATH:" in
275 path-remove path "$dir"
278 path-remove path "$dir"
289 if [ $# -eq 0 ]; then
297 # --- Switching security worlds ---
300 local nfast=${NFAST_HOME-/opt/nfast}
304 echo "${NFAST_KMDATA#$nfast/kmdata-}"
309 elif [ -d "$nfast/kmdata-$1" ]; then
310 kmdata=$nfast/kmdata-$1
312 echo >&2 "world: can't find world $1"
317 0) export NFAST_KMDATA=$kmdata ;;
324 # --- Fix `man' under Slowaris ---
334 case "$arg" in [0-9]*) man[i+=1]="-s" ;; esac
337 command man "${man[@]}"
342 # --- For `root' use -- some simple molly-guards ---
344 if (( UID == 0 )); then
345 alias rm='rm -i' cp='cp -i' mv='mv -i'
349 [ -f "$HOME/.bashrc-local" ] && . "$HOME/.bashrc-local"