#
# Generic .zshrc file for zsh 3.1
#
# .zshrc is sourced in interactive shells.  It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#

# Search path for the cd command
cdpath=(.. ~ ~/src ~/zsh)

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

umask 022

# Set up aliases
alias mv='nocorrect mv'       # no spelling correction on mv
alias cp='nocorrect cp'       # no spelling correction on cp
alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
alias j=jobs
alias pu=pushd
alias po=popd
alias d='dirs -v'
alias h=history
alias grep=egrep
alias ls='ls -F --color=tty'
alias ll='ls -l'
alias la='ls -a'
alias l='ls'
alias mk='make'
alias les='less'

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

# List only file beginning with "."
alias lsa='ls -ld .*'

# Shell functions
setenv() { export $1=$2 }  # csh compatibility
chpwd () {ls $1 } # get file list automagically

# Where to look for autoloaded function definitions
# fpath=(~/.zfunc)

# Autoload all shell functions from all directories
# in $fpath that have the executable bit on
# (the executable bit is not necessary, but gives
# you an easy way to stop the autoloading of a
# particular shell function).
for dirname in $fpath
do
#  autoload $dirname/*(.x:t)
  autoload $dirname/*
done

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

manpath=(/usr/man /usr/X11R6/man /usr/lang/man /usr/local/man /var/qmail/man /var/catman)
export MANPATH

# Filename suffixes to ignore during completion
fignore=(.o .c~ .old .pro)

# Hosts to use for completion
hosts=(`hostname` ftp.math.gatech.edu prep.ai.mit.edu wuarchive.wustl.edu)

# Set prompts
PROMPT='%n@%m:%~%#'    # default prompt
# RPROMPT=' %~'     # prompt for right side of screen

# Some environment variables
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/var/qmail/bin:~/bin
export MAIL=$HOME/Mailbox
export LESS=-cex3M
export HELPDIR=/usr/local/lib/zsh/help  # directory for run-help function to find docs
export POVINI=~/etc/povrayrc
export DICOPT=-pgf/usr/local/dictionary/chujiten/data/honmon
export MAILDROP=~/Mailbox
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/gimp11/lib
export LESS="-rP?f%f:stdi.\ %l/%L\ %p\%"
export PAGER="less"
export INFOPATH=/usr/info:/usr/local/info:/usr/X11R6/info

HISTSIZE=2048
HISTFILE=~/etc/history
SAVEHIST=2048
DIRSTACKSIZE=16

# Set/unset  shell options
setopt notify pushdtohome cdable_vars
setopt auto_cd longlistjobs auto_list automenu
setopt autoresume histignoredups pushdsilent noclobber
setopt autopushd pushdminus extended_glob rcquotes mailwarning
setopt rm_star_silent nobeep append_history
setopt complete_in_word glob_dots login long_list_jobs print_eight_bit
setopt pushd_ignore_dups share_history
unsetopt bgnice autoparamslash menu_complete correct flow_control

# Some nice key bindings
#bindkey '^X^Z' universal-argument ' ' magic-space
#bindkey '^X^A' vi-find-prev-char-skip
#bindkey -s '\M-/' \\\\
#bindkey -s '\M-=' \|

open-space (){
	zle magic-space
	zle backward-char
	}
zle -N open-space open-space

bindkey '^U' open-space
bindkey -e               # emacs key bindings
bindkey ' ' magic-space  # also do history expansino on space
bindkey '^I' complete-word
bindkey '^V' menu-complete
bindkey '^Q' reverse-menu-complete
bindkey '^ ' set-mark-command
bindkey '^W' kill-region
bindkey '^Z' accept-and-hold
bindkey '^X^Y' copy-prev-word


stty erase '^H'
stty stop undef
stty start undef
stty intr '^C'

# in X environ, terminal specific settings
case $TERM in
    *[Ex]term*)
        precmd () {print -Pn "\e]0;%n@%m: %~\a"}
		export LANG=C
		unset LANGUAGE
        ;;
	kterm*)
        precmd () {print -Pn "\e]0;%n@%m: %~\a"}
		alias mule='mule -nw'
		export LANG=ja_JP.ujis
		;;
esac

if [ -f ~/etc/zshcompctl ]
then
	source ~/etc/zshcompctl
fi

if [ -f ~/etc/spczsh ]
then
	source ~/etc/spczsh
fi
