# For interactive shells
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd autopushd extendedglob nohup nomatch histignorespace histlexwords histverify cbases
unsetopt beep histbeep listbeep flowcontrol
bindkey -e

# Completion
zstyle :compinstall filename '/home/david/.zshrc'
autoload -Uz compinit && compinit

DIRSTACKSIZE=16
case $TERM in
  xterm*)
    precmd () {print -Pn "\e]0;%n@%m: %~\a"}
    ;;
esac

autoload -U colors && colors
PS1="%{$fg[black]%}[%{$fg[yellow]%}%h%{$fg[black]%}] %{%(!.$fg[red].$fg[green])%}%8>..>%n%>>%{$fg[white]%}@%{$fg[blue]%}%12>..>%m%>>%{$fg[white]%}:%{$fg[green]%}%32<...<%~%<<%{$fg[white]%}%#%{$reset_color%} "

# LS Colors
alias ls='ls --color'
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}

# Load oh-my-zsh
if [ -d $HOME/.oh-my-zsh ] ; then
  ZSH=$HOME/.oh-my-zsh
  ZSH_THEME="matir"
  ZSH_CUSTOM="$HOME/.zsh_custom"
  plugins=(git encode64 gpg-agent pep8 pip python tmux urltools extract sudo virsh virtualenv command-not-found jekyll)
  test -f /usr/share/virtualenvwrapper/virtualenvwrapper.sh && plugins+=(virtualenvwrapper)
  source $ZSH/oh-my-zsh.sh
  unset ZSH_THEME
  unset ZSH_CUSTOM
fi

# .profile is universal
# but after oh-my-zsh to use anything setup there
. ~/.profile
# Deduplicate the path
typeset -U path


# Keybindings
bindkey '^[[A' history-search-backward
bindkey '^[[B' history-search-forward
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word

# Source extras and aliases if interactive
if [[ $- == *i* ]] ; then
  if [[ -e $HOME/.aliases ]] ; then source $HOME/.aliases ; fi
  for file in $HOME/.zshrc.d/* ; do source "$file" ; done
fi

# Load any local settings
if [ -e $HOME/.zshrc.local ] ; then source $HOME/.zshrc.local ; fi
