# # $Id: .bashrc,v 1.6 1996/12/08 20:33:42 mdw Exp $ # # Bash session things # if [ -z "$__mdw_bashrc" ]; then __mdw_bashrc=done [ -z "$__mdw_profile" -a -r $HOME/.bash_profile ] && . $HOME/.bash_profile [ -r /etc/bashrc ] && . /etc/bashrc # --- First of all, set up the prompt string --- if [ -t 0 ]; then if [ "$TERM" = "dumb" ]; then if (( EUID == 0 )); then PS1="# "; else PS1="\$ "; fi PS2="> " PS4="+ " else case "$TERM" in linux*|screen*|xterm*|vt100*) bold='\[\]' unbold='\[\]' nl='\[ \]' ;; *) bold='' unbold='' nl='' ;; esac if (( EUID == 0 )); then left="«" right="»" elif [ "$__mdw_tty" = "`tty`" ]; then left="<" right=">" else left="[" right="]" export __mdw_tty="`tty`" fi if [ -z "$SSH_CLIENT" ] && [ "$__mdw_sechost" != "`hostname`" ] then sec_l='(' sec_r=')' fi PS1="$nl$bold$left$sec_l\\h$sec_r \\w$right$unbold" PS2="$PS1 $bold>$unbold " fi fi # is stdin a tty? # --- Little preferences --- notify=1 set -b shopt -u cdable_vars shopt -s cdspell shopt -s checkhash shopt -s checkwinsize shopt -s cmdhist shopt -u dotglob shopt -s expand_aliases shopt -s extglob shopt -s histappend shopt -s histreedit shopt -u histverify shopt -s hostcomplete shopt -s huponexit shopt -s interactive_comments shopt -s lithist shopt -u mailwarn shopt -u nocaseglob shopt -u nullglob shopt -s promptvars shopt -u shift_verbose shopt -s sourcepath # --- Set the CDPATH --- # # CDPATH=~/src:/usr/src:/usr/lib:/usr/share # dots=.. # i=6 # while (( i > 0 )); do # CDPATH=$CDPATH:$dots # dots=$dots/.. # (( i -= 1 )) # done # CDPATH=$CDPATH:/ # --- Some colour `ls' support --- [ "${TMPDIR+yes}" ] || eval `tmpdir -b` if [ -x /usr/bin/dircolors -o -x /usr/local/bin/dircolors ] && [ "$TERM" != "dumb" ]; then eval `dircolors -b ~/.dircolors` else unset LS_COLORS fi ls () { if [ -t 1 ]; then command ls $LS_OPTIONS ${LS_COLORS+--color=auto} "$@" else command ls "$@" fi } # --- Setting xterm titles --- # # This doesn't work so well any more. :-( # if [ -e /usr/lib/bash/xtitle.so ]; then # enable -f /usr/lib/bash/xtitle.so xtitle # elif [ -e /usr/local/lib/xtitle.so ]; then # enable -f /usr/local/lib/xtitle.so xtitle # elif [ -e $HOME/lib/bash/xtitle.so ]; then # enable -f $HOME/lib/bash/xtitle.so xtitle # else # xtitle () { return 1; } # fi xtitle () { return 1; } entitle () { local t="`xtitle -q`" st xtitle "$t $1" shift "$@"; st=$? xtitle "$t" return $st } # --- Set up some simple aliases --- alias cx='chmod a+x' alias which="command -v" alias ssync="rsync -e ssh" alias rootly="entitle root become -g0 root" alias r=rootly alias re="rootly sensible-editor" alias eh="entitle 'Egham Hills 90210' tf eh" alias news="entitle Usenet slrn" alias splitvt='splitvt -t "`xtitle -q || echo xterm` splitvt"' alias pstree="pstree -Ghl" alias cdtmp='cd ${TMPDIR-/tmp}' alias pushtmp='pushd ${TMPDIR-/tmp}' alias e="sensible-editor" alias svn="svnwrap svn" @ () { local t="`xtitle -q`" host="$1" shift xtitle "$t [$host]" ssh "$host" "$@" xtitle "$t" } # --- Make `xt' start an xterm, maybe logging into a remote host --- xt () { case "$1" in @*) local remote=${1#@} title shift if [ $# -gt 0 ]; then title="xterm [$remote] $1" else title="xterm [$remote]" fi (xterm -title "$title" -e ssh $remote "$@" &) ;; *) (xterm "$@" &) ;; esac } # --- Turning on and off core dumps --- core () { case "x$1" in xon|xy|xyes) ulimit -Sc `ulimit -Hc` ;; xoff|xn|xno) ulimit -Sc 0 ;; x) local l=`ulimit -Sc` case $l in 0) echo "Core dumps disabled" ;; unlimited) echo "Core dumps enabled" ;; *) echo "Core dump limit is $l blocks" ;; esac ;; *) echo >&2 "usage: core [yn]" return 1 ;; esac } # --- Fix `man' under Slowaris --- case "$MACHTYPE" in *solaris*) man () { declare -i i=0 declare arg declare -a man for arg; do case "$arg" in [0-9]*) man[i+=1]="-s" ;; esac man[i+=1]="$arg" done command man "${man[@]}" } ;; esac # --- For `root' use -- some simple molly-guards --- if (( UID == 0 )); then alias rm='rm -i' cp='cp -i' mv='mv -i' set -o noclobber fi fi