autoload -U compinit
compinit

setopt correct
setopt cdable_vars
setopt extended_glob
setopt prompt_subst
setopt histignoredups

bindkey -v

# apparently this is a bad way to do this.  http://www.kdedevelopers.org/node/4051
function precmd {
	git_ps1 () {
		local dirty=''
		local st="$(git status 2> /dev/null | tail -n1)" 
		if [ "$st" = "nothing added to commit but untracked files present (use \"git add\" to track)" ]; then
			dirty='**'
		elif [ "$st" != "nothing to commit (working directory clean)" ]; then
			dirty='*'
		fi
		local branch="$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
		if [ -n "$branch" ]; then
			printf " [%s]" "$branch$dirty"
		fi
	}
	GITBRANCH="$(git_ps1)"
}

PROMPT=$'%{\e[1;34m%}%n@%m %2~$GITBRANCH %(!.#.$)%{\e[1;00m%} '
RPROMPT='%(?..%?)'

tab () {
  osascript 2>/dev/null <<EOF
  tell application "System Events"
    tell process "Terminal" to keystroke "t" using command down
    end
    tell application "Terminal"
    activate
    do script with command "cd $PWD" in window 1
    do script with command "$*" in window 1
  end tell
EOF
}

HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.history_zsh

export EDITOR='vi'


alias vi='/Applications/MacVim.app/Contents/MacOS/Vim'
alias vim='vi -p'
alias gvim='vim -p -g'

alias ls='ls -G'

CDPATH=.:~/
PATH=~/.bin:/usr/local/bin:/usr/local/sbin:$PATH

