kparnell /.bashrc

My .bashrc with some helper functions I like, and a few menus at login.
# environment variables
source /etc/profile
export PATH=".:$PATH:/usr/local/src/jruby-1.0/bin"
export CLASSPATH="$CLASSPATH:/Users/kenny/classes"
export LC_CTYPE=en_US.UTF-8
export SVN_EDITOR="vim"
export EDITOR="vim"
export PERL5LIB="/usr/local/lib/svn-perl"
export TERM=xterm-color
export LIMPRUNTIME=/usr/local/src/limp-0.3
export GPGKEY=DF46EE16

# custom prompt
PS1="\[\033[31m\]<\h:\u> [\d \t] \w\n \$ \[\033[0m\]"

# reload bashrc after it is modified
alias reload="source ~/.bashrc"

# list current directory sizes
alias dut="du -h -c -d 1"

alias ls="ls -GF"
alias ll="ls -lh"
alias cls="clear; ls"
alias cl="cd $1; ls"
alias gvim="open -a MacVim"

# add all ? to svn
alias svna="svn st | grep ^\? | sed 's/^\?[ \t]*//' | xargs svn add"

# revert all A
alias svnra="svn st | grep ^A | sed 's/^A[ \t]*//' | xargs svn revert"

# list 10 biggest files in current path
alias big_files="BLOCKSIZE=1048576; du -x | sort -nr | head -10"

# Vars for functions
OPTIONS="Yes No"

# Check for ssh-agent
function check_ssh_agent {
    if [[ -z $SSH_AUTH_SOCK ]]; then
       SOCKETFILE=/Users/${USER}/tmp/ssh/ssh-agent.sock
    else
       SOCKETFILE=${SSH_AUTH_SOCK}
    fi

    /bin/ps -wU ${USER} | /usr/bin/grep "[s]sh-agent" > /dev/null
    if [[ $? -gt 0 ]]; then
       /bin/rm -f ${SOCKETFILE}
       /usr/bin/ssh-agent -a ${SOCKETFILE} > /dev/null
       /bin/chmod 600 ${SOCKETFILE}
    fi

    if [ "$(ssh-add -l)" = "The agent has no identities." ]; then
        echo "Add ssh keys to agent?"
        select opt in $OPTIONS; do
            if [ "$opt" = "Yes" ]; then
                ssh-add
                break
            else
                break
            fi
        done
    fi
}

# tab completion for rake
complete -C /usr/local/bin/rakecomplete -o default rake

# tab completion for django
. /usr/local/src/django-trunk/extras/django_bash_completion

# tab completion for ssh hosts
SSH_COMPLETE=( $(cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
uniq | \
egrep -v [0123456789]) )
complete -o default -W "${SSH_COMPLETE[*]}" ssh

# auto completion for sudo
SUDO_COMPLETE=( $(echo $PATH | sed 's/:/\n/g' | xargs ls 2>/dev/null) )
complete -o default -W "${SUDO_COMPLETE[*]}" sudo

# download and untargz
function dtgz {
         if [ $# -gt 0 ]; then
                 for l in $@; do
                         curl $l | tar -xz
                 done
         else
                 echo "Usage: dtgz url [url2, url3, ...]" 1>&2
         fi 
}

# sudo vim
function svim {
        sudo vim $@
}

# create a directory and make it the working directory
function mkcdr {
	mkdir -p $1
	cd $1
}

# edit ~/.bashrc and reload it
function ebrc {
	vim ~/.bashrc
	reload
}

# show . files in Finder
function finder_display_dot_files {
	case $# in
		1) defaults write com.apple.finder AppleShowAllFiles $1; killall Finder ;;
		*) echo "usage: finder_display_dot_files TRUE\|FALSE" 1>&2
	esac
}

# run screen if not currently running
function run_screen {
   echo "Run screen?"
   if [ -z $(ps | grep screen | grep -v grep) ]; then
       select opt in $OPTIONS; do
          if [ "$opt" = "Yes" ]; then
              exec screen
          else
              break
          fi
      done
  fi
}

check_ssh_agent
run_screen