# Paul's zshrc (paul@luon.net)
#
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
# $Id: .zshrc,v 1.17 2002/03/07 11:15:20 paul Exp $

[[ $UID > 0 && $UID == $GID ]] && umask 002 || umask 022

### LIMITS:
# Use hard limits, except for a smaller stack and no core dumps
unlimit
limit core 0
limit -s

### ENVIRONMENT:
# Hostname colors:
case `hostname` in 
  speed)	COLOR=[30m ;;
  distance)	COLOR=[31m ;;
  target)	COLOR=[32m ;;
  *)		COLOR=[36m ;;
esac

# Username color:
case $USER in
  root)         UCOLOR=%B[31m ;;
esac
  
# Commands that export environment variables:
eval $(dircolors)
eval $(lesspipe)

# Environment variables
CVS_RSH=ssh
DIRSTACKSIZE=20
HISTFILE=~/.zsh_history
HISTSIZE=1000
LOGCHECK=300                  # check every 5 min for login/logout activity
LS_OPTIONS='--color=auto -F'
MAIL=/var/mail/$USER
MAILCHECK=120
MAILPATH="$HOME/Mail/*?You've got new mail in \$_"
RSYNC_RSH=ssh
SAVEHIST=1000
WATCHFMT='%n %a on tty %l from %M at %T.'
ZLS_COLORS=$LS_COLORS
fpath=($fpath ~/.zfunc)
path=(/usr/local/bin /usr/bin /bin /usr/bin/X11 /usr/local/games /usr/games $HOME/bin)
watch=(notme)                # watch for everybody but me

export CVS_RSH MAIL RSYNC_RSH path

# Set prompts
export RPS1=" %40<...<%~"
export PS1="%{$UCOLOR%}%n%{[0m%}@%B%{$COLOR%}%m%b%{[0m%} %l%# "

### ALIASES:
# Set up often used aliases
alias F='tail -f'
alias cp='nocorrect cp'       # no spelling correction on cp
alias d='dirs -v'
alias grep=egrep
alias h=history
alias j=jobs
alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
alias mv='nocorrect mv'       # no spelling correction on mv

# ls aliases:
alias ls="ls $LS_OPTIONS"
alias lsl="ls -l $LS_OPTIONS"
alias lsa="ls -a $LS_OPTIONS"
alias lsal="ls -al $LS_OPTIONS"
alias lsla=lsal

# List only directories and symbolic
# links that point to directories
alias lsd="ls -ld *(-/DN) $LS_OPTIONS"

# List only file beginning with "."
alias lsh="ls -d .* $LS_OPTIONS"
alias lslh="ls -ld .* $LS_OPTIONS"

# Global aliases
# These do not have to be at the beginning of the command line.
alias -g L='| less'
alias -g H='| head'
alias -g T='| tail'

### MODULES:
# The following line is meant for compatibility with previous versions.
# The use of these module aliases is deprecated.
zmodload -A cap=zsh/cap clone=zsh/clone compctl=zsh/compctl\
	    complete=zsh/complete complist=zsh/complete computil=zsh/computil\
	    deltochar=zsh/deltochar example=zsh/example files=zsh/files\
	    mapfile=zsh/mapfile mathfunc=zsh/mathfunc parameter=zsh/parameter\
	    rlimits=zsh/rlimits sched=zsh/sched stat=zsh/stat zftp=zsh/zftp\
	    zle=zsh/zle zleparameter=zsh/zleparameter

autoload complist

### OPTIONS:
# Set/unset shell options
setopt   checkjobs completeinword extendedhistory hashlistall
setopt	 sharehistory notify globdots correct pushdtohome cdablevars autolist
setopt   correctall autocd longlistjobs histignoredups pushdsilent noclobber
setopt   autopushd pushdminus extendedglob rcquotes mailwarning
unsetopt autoresume bgnice autoparamslash

### STYLE/COMPLETION:
# New style completion (only enabled if zsh version is newer than 4.0
if [[ $ZSH_VERSION > 4.0 ]]; then
# The following lines were added by compinstall
zstyle ':completion:*' auto-description 'Specify: %d'
zstyle ':completion:*' completer _expand _complete _correct 
zstyle ':completion:*' completions 1
zstyle ':completion:*' file-sort name
zstyle ':completion:*' format 'Completing options for %d:'
zstyle ':completion:*' glob 1
zstyle ':completion:*' group-name ''
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
zstyle ':completion:*' matcher-list '' 'l:|=* r:|=*' 'r:|[._-/]=* r:|=*' 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' max-errors 1 numeric
zstyle ':completion:*' menu select=8
zstyle ':completion:*' original true
zstyle ':completion:*' prompt 'E %e:'
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*' squeeze-slashes true
zstyle ':completion:*' substitute 1
zstyle ':completion:*' verbose true

# specific stuff
zstyle ':completion:*:apt-get:*' use-cache on
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle -e ':completion:*:hosts' hosts 'reply=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'

zstyle :compinstall filename "$HOME/.zshrc"

autoload -U compinit
compinit
# End of lines added by compinstall
fi

### KEYBINDINGS:
# Some nice key bindings
bindkey '^R' history-incremental-search-backward
bindkey ' ' magic-space  # also do history expansion on space

bindkey -M vicmd "\033[3~" vi-delete-char
bindkey -M vicmd "\033OH" vi-beginning-of-line
bindkey -M vicmd "\033OF" vi-end-of-line

bindkey -M viins "\033[A" up-line-or-history
bindkey -M viins "\033[B" down-line-or-history
bindkey -M viins "\033[C" vi-forward-char
bindkey -M viins "\033[D" vi-backward-char
bindkey -M viins "\033OA" up-line-or-history
bindkey -M viins "\033OB" down-line-or-history
bindkey -M viins "\033OC" vi-forward-char
bindkey -M viins "\033OD" vi-backward-char
bindkey -M viins "^Xp" push-line

bindkey -v # VI-keybindings
#bindkey -e # Emacs-keybindings

### LOCAL SETTINGS:
# Source local ~/.zshrc.<host> if exists
LOCALZSHRC=$HOME/.zshrc.$(hostname)

test -r $LOCALZSHRC && source $LOCALZSHRC
