# ZSH DIR
export ZSHDIR=$HOME/.zsh

# for custom functions
fpath=($ZSHDIR/functions $fpath)


# PROMPT
autoload -U promptinit
promptinit
autoload -U colors
colors
#prompt numerodix magenta white white green red
#prompt numerodix


# TAB COMPLETION
autoload -U compinit
compinit -i

zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'

#allow tab completion in the middle of a word
setopt COMPLETE_IN_WORD
##tab completion moves to end of word
setopt ALWAYS_TO_END
setopt listtypes 


# PROCS
# %1 killed. will show up exactly when it is killed.
setopt interactivecomments
unsetopt flowcontrol


# HISTORY
HISTFILE=$HOME/.histfile
HISTSIZE=2000
SAVEHIST=$HISTSIZE

#for sharing history between zsh processes
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
unsetopt HIST_SAVE_BY_COPY	# fix 'can't write history file' bug

setopt hist_ignore_all_dups
setopt hist_ignore_space


setopt autocd	# cd /etc => /etc
setopt extendedglob		# cp ^*.(tar|bz2|gz)


# KEY BINDINGS
bindkey -e bold # emacs key bindings
bindkey ' ' magic-space # also do history expansion on space

# setup backspace correctly
#stty erase `tput kbs`

#delete key
bindkey '\e[3~' delete-char

#home, end
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
case $TERM in (xterm*)
	bindkey '\e[H' beginning-of-line
	bindkey '\e[F' end-of-line ;;
esac

#insert
bindkey '\e[2~' overwrite-mode

#tab completion
bindkey '^i' expand-or-complete-prefix

#never ever beep ever
setopt NO_BEEP


# Shell functions
setenv() { export $1=$2 } # csh compatibility



[[ -f ~/.myshell/common ]] && \
source ~/.myshell/common

# $hostcolor should now be set
if [ ! -z "$hostcolor" ]; then
	source ~/.myshell/colors_zsh
	hostcolor=$(eval "echo \$$(echo $hostcolor)")
fi
prompt numerodix $hostcolor


[[ -f ~/.myshell/zsh_local ]] && \
source ~/.myshell/zsh_local
