~ fazibear /.zshrc

HISTFILE=~/.histfile
HISTSIZE=2000
SAVEHIST=2000

setopt inc_append_history
setopt hist_ignore_all_dups
setopt hist_ignore_space
#setopt correctall
setopt autocd
setopt extendedglob
setopt checkjobs

autoload -U colors
colors

autoload -Uz compinit
compinit

autoload -U zstyle+

zstyle ':completion:*' completer _complete _list _oldlist _expand _ignored _match _correct _approximate _prefix
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format "%{$fg_bold[green]%}%d%{$reset_color%}"
zstyle ':completion:*:messages' format "%{$fg_no_bold[yellow]%}%d%{$reset_color%}"
zstyle ':completion:*:warnings' format "%{$fg_no_bold[red]%}No matches for: %d%{$reset_color%}"
zstyle ':completion:*:corrections' format "%{$fg_bold[blue]%}%B%d (errors: %e)%b%{$reset_color%}"
zstyle ':completion:*' group-name ''
zstyle ':completion:*' file-sort name
zstyle ':completion:*' menu select=1
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:kill:*:processes' command 'ps -axco pid,user,command'
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'

bindkey "^[[A" up-line-or-history
bindkey "^[[B" down-line-or-history
bindkey "^[[6~" history-beginning-search-forward
bindkey "^[[5~" history-beginning-search-backward
bindkey "^[[1~" beginning-of-line
bindkey "^[[4~" end-of-line

bindkey "^S" history-incremental-search-forward 
bindkey "^R" history-incremental-search-backward

if [[ "$TERM" != "dumb" ]]; then
    export PROMPT="%{$fg_bold[red]%}%n%{$fg_bold[white]%}@%{$fg_bold[blue]%}%m%{$fg_bold[white]%}>%{$reset_color%} "
    export RPROMPT="%{$fg_no_bold[green]%}[%{$fg_no_bold[yellow]%}%~%{$fg_no_bold[green]%}]%{$reset_color%}"
else
    export PROMPT="%(?..[%?] )%n@%m:%~> "
fi

if [[ $TERM == screen* ]]; then
  export SCREEN_TERM=$TERM;
  export TERM=xterm
fi

precmd () {
  print -Pn "\e]0;%n@%m:%~\a"
  if [[ $SCREEN_TERM == screen* ]]; then
    echo -ne "\ek>\e\\"
  fi
}

preexec () {
  print -Pn "\e]0;%n@%m:%~ <$1>\a"
  if [[ $SCREEN_TERM == screen* ]]; then
    echo -ne "\ek${1[(wr)^(*=*|sudo|-*)]}\e\\"
  fi
};

_rake_does_task_list_need_generating () {
  if [ ! -f .rake_tasks ]; then return 0;
  else
    accurate=$(stat -c%Z .rake_tasks)
    changed=$(stat -c%Z Rakefile)
    return $(expr $accurate '>=' $changed)
  fi
}

_rake () {
  if [ -f Rakefile ]; then
    if _rake_does_task_list_need_generating; then
      echo "\nGenerating .rake_tasks..." > /dev/stderr
      rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
    fi
    compadd `cat .rake_tasks`
  fi
}

compdef _rake rake

#alias ls='ls -G'
alias ls='ls --color=always'
alias serv='script/server -p 30666'

export EDITOR=vim