# my ~/.bashrc config file

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history.
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
fi

# personal stuff after here ---------------------------------------------------

alias rm='rm -i'
alias mv='mv -i'
alias ll='ls -l'
alias la='ls -la'
alias lrt='ls -lrt'
alias igrep='grep -i'
alias svnstat='svn status | egrep -v "^\?"'
alias svndiff='svn diff | kompare -o -'
alias emacs='emacs --fullheight --geometry 80'

# edit within a server emacs
function em () {
emacsclient --no-wait $*
}

# list haskell source files
function hsls () {
find . -regex ".*\.hs"
}

# grep in haskell source files
function hsgrep () {
grep $1 $(hsls)
}

function hsigrep () {
grep -i $1 $(hsls)
}

function hsagrep () {
agrep -3 $1 $(hsls)
}

alias ocaml='rlwrap ocaml' # adds line editing to the ocaml interpreter

export EDITOR=emacs
export PAGER=less

# svn side-by-side diff
function sbsdiff () {
svn --diff-cmd "diff" \
--extensions "--suppress-common-lines -y --width=160" diff
}