rails=~/dev/shared/rails

lh=~/dev/entp/lighthouse/code/lighthouse.application
ts=~/dev/entp/tender
entp=~/dev/entp
lrr=~/dev/lrr

iphone=~/dev/me/iphone
cocoa=~/dev/me/cocoa
ruby=~/dev/me/ruby

pdxc=~/dev/lrr/rails/portlandcrime
ww=~/dev/lrr/rails/we_watched

tiphone=~/dev/thirdparty/iphone
tcocoa=~/dev/thirdparty/cocoa
truby=~/dev/thirdparty/ruby

export PS1="%d> "

# Input stuff.

bindkey -e


# History stuff.

setopt HIST_VERIFY
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt EXTENDED_HISTORY
setopt HIST_IGNORE_DUPS

HISTSIZE=256
SAVEHIST=256
HISTFILE=~/.zsh-history


# Visual stuff.

autoload colors; colors

if [[ x$WINDOW != x ]]
then
    SCREEN_NO="%B$WINDOW%b "
else
    SCREEN_NO=""
fi

PS1="%n@%m:%~%# "

# Directory stuff.

setopt AUTO_NAME_DIRS

# Speed stuff.

#setopt NO_BEEP
setopt AUTO_CD
setopt MULTIOS
setopt CDABLEVARS

alias startmongo='mongod run --config /usr/local/Cellar/mongodb/1.6.5-x86_64/mongod.conf'

alias avmplus='shell'
alias c='cd'
alias pu='pushd'
alias po='popd'

alias mr='mate app config db lib public script spec test Gemfile doc'
alias .='pwd'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'

alias _='sudo'
alias ss='setsid'

alias g='grep -in'

alias d='darcs'
alias s='svn'
alias e='mate'

alias utb='tar jxvf'
alias utz='tar zxvf'

alias ls='ls -GF'

alias rfind='find . -name *.rb | xargs grep -n'
alias grep='GREP_COLOR="1;37;41" LANG=C grep --color=auto' #use GREP_COLOR=7 to highlight whitespace


# Git stuff
alias gd='git diff'
alias gl='git log'
alias gs='git show'
alias gb='git branch'
alias gc='git commit'
alias gca='git commit -a'
alias gst='git status'
alias gls='git log --stat --summary'
alias gch='git checkout'
alias gdch='git diff --cached head'
alias gtb='git branch --track'
alias gpo='git pull origin'

alias doxygen='/Applications/Doxygen.app/Contents/Resources/doxygen'

setopt PROMPT_SUBST
#RPROMPT='%B<-%b %? %17>..>%B$(~/.git-branch-shell.sh)%b'

bindkey '\ew' kill-region

bindkey -s '\el' "ls\n"
bindkey -s '\e.' "..\n"

# Shitty bloat

autoload -U incremental-complete-word
zle -N incremental-complete-word
bindkey "^Xi" incremental-complete-word ## C-x-i

#setopt EXTENDED_GLOB
setopt noautomenu
setopt COMPLETE_IN_WORD
setopt ALWAYS_TO_END

unsetopt flowcontrol

WORDCHARS=''

autoload -U compinit
compinit

zmodload -i zsh/complist

zstyle ':completion:*' list-colors ''
zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts )

unsetopt MENU_COMPLETE
setopt AUTO_MENU

bindkey -M menuselect '^o' accept-and-infer-next-history

zstyle ':completion:*:*:*:*:*' menu yes select
# zstyle ':completion:*:*:*:*:processes' force-list always

zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts`

# hosts=(teepee wigwam google.com)
# zstyle ':completion:*' hosts $hosts

function title {
    if [[ $TERM == "screen" ]]; then
      # Use these two for GNU Screen:
      print -nR $'\033k'$1$'\033'\\\

      print -nR $'\033]0;'$2$'\a'
    elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then
      # Use this one instead for XTerms:
      print -nR $'\033]0;'$*$'\a'
    fi
}

function precmd {
    title zsh "$PWD"
}

function preexec {
    emulate -L zsh
    local -a cmd; cmd=(${(z)1})
    title $cmd[1]:t "$cmd[2,-1]"
}

function pap { curl -s $1 | patch -p0; }

function ruby184 { PATH=~/local/bin:$PATH }

function htmlstub { mkdir -p $1/img $1/js $1/css; touch $1/js/app.js; cd $1; }
function visstub { 
  mkdir -p $1/img $1/js $1/css $1/cof $1/js/ven; 
  cd $1; 
  curl "https://github.com/andyet/polymaps/raw/master/polymaps.js" -L -o js/ven/polymaps.js
  curl "https://github.com/mbostock/d3/raw/master/d3.js" -L -o js/ven/d3.js
  curl "https://github.com/mbostock/d3/raw/master/d3.layout.js" -L -o js/ven/d3.layout.js
  curl "https://github.com/mbostock/d3/raw/master/d3.csv.js" -L -o js/ven/d3.csv.js
  curl "https://github.com/mbostock/d3/raw/master/d3.js" -L -o js/ven/d3.js
  curl "https://github.com/documentcloud/underscore/raw/master/underscore.js" -L -o js/ven/underscore.js
  curl "http://datejs.googlecode.com/files/date.js" -L -o js/ven/date.js
  curl "https://github.com/documentcloud/backbone/raw/master/backbone.js" -L -o js/ven/backbone.js
  
  echo "$ ->\n  console.log 'find me in app/coffee'" > cof/app.coffee; 
  echo "desc 'watch for changes'\ntask :watch do\n  exec 'coffee -o js -w ./cof/*.coffee'\nend" > Rakefile;
}


# Environment variables.

#export EDITOR='/usr/bin/mate'
export BUNDLER_EDITOR=/usr/bin/mate
export GEM_OPEN_EDITOR=/usr/bin/mate
export PAGER=less
export PATH=/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin::/usr/local/share/npm/bin:/Users/justin/dev/thirdparty/perl/circos-0.52/bin:$PATH
export PGDATA=$HOME/Databases/Postgres
export CLASSPATH=$HOME/java/junit-4.1.jar:/Users/Caged/dev/bins/rhino/js.jar
export JRUBY_HOME=$HOME/p/jruby
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
export JRUBY_SHELL=/bin/zsh
export AVM=avmplus
export EVENT_NOKQUEUE=1
export LC_CTYPE=en_US.UTF-8
export RIPDIR=/Users/justin/dev/rip

export EC2_HOME=~/.ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`
export EC2_CERT=`ls $EC2_HOME/cert-*.pem`
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/

export RUBYLIB=~/dev/thirdparty/ruby/mrtoolkit/lib
export CLANG_ANALYZER="/Developer/checker-0.218/scan-build"

# export PATH=`brew --prefix`/bin:$PATH
export PATH=$PATH:/usr/local/narwhal/bin
export MANPATH=`brew --prefix`/share/man:$MANPATH
export MAGICK_HOME=/usr/local

export NODE_PATH=/usr/local/lib/node:$NODE_PATH

export CAPP_BUILD=/Users/justin/dev/shared/cappuccino
export PYTHONPATH=/usr/local/lib/python

unsetopt auto_name_dirs

if [[ -s /Users/justin/.rvm/scripts/rvm ]] ; then source /Users/justin/.rvm/scripts/rvm ; fi