#
# /etc/zshrc is sourced in interactive shells.  It contain the basic
# configuration for keys umask PROMPT and variable
# If no ~/.zshrc exist then load the default
# /usr/share/zsh/$ZSH_VERSION/zshrc_default
#
# If you have problems about this semantics please send comment to :
# Chmouel Boudjnah <chmouel@mandrakesoft.com>

if [[ $(id -gn) = $USERNAME && $EUID -gt 14 ]]; then
        umask 002
else
        umask 022
fi

# Get keys working
if [[ $TERM = "linux" ]];then
	bindkey "^[[2~" yank
	bindkey "^[[3~" delete-char
	bindkey "^[[5~" up-line-or-history
	bindkey "^[[6~" down-line-or-history
	bindkey "^[[1~" beginning-of-line
	bindkey "^[[4~" end-of-line
elif [[ $TERM = "xterm" || $TERM = "rxvt"  ]];then
	bindkey "^[[2~" yank
	bindkey "^[[3~" delete-char
	bindkey "^[[5~" up-line-or-history
	bindkey "[8~" end-of-line
	precmd () { print -Pn "\e]0;%n@%m: %~\a" }
fi

# For Beginning/end of line pickup the good one
# 
# XTerm:
#   bindkey "^[[1~" beginning-of-line
#   bindkey "^[[4~" end-of-line
#
# RXVT:
#   bindkey "^[[7~" beginning-of-line
#   bindkey "^[[8~" end-of-line
#
# Gnome/KDE-Terminal:
#   bindkey "^[OF" end-of-line
#   bindkey "^[OH" beginning-of-line
#

# Set prompts
PROMPT="%n@%m %3~ %(!.#.$) "    # default prompt
#RPROMPT=' %~'     # prompt for right side of screen

# Some environment variables
path=($path $HOME/bin)
export HISTFILE=${HOME}/.bash_history
export HISTSIZE=1000
export SAVEHIST=1000
export USER=$USERNAME
export HOSTNAME=$HOST

# bindkey -v             # vi key bindings
bindkey -e               # emacs key bindings

for profile_func ( /etc/profile.d/*.sh ) source $profile_func

unset profile_func

# See comment at top.
if [[ ! -r ${ZDOTDIR:-$HOME}/.zshrc ]];then
    if  [[ -f /usr/share/zsh/$ZSH_VERSION/zshrc_default ]];then
	source /usr/share/zsh/$ZSH_VERSION/zshrc_default
    fi
fi
