#
# /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
(( ${+terminfo[kich1]} )) && bindkey "${terminfo[kich1]}" yank
(( ${+terminfo[kdch1]} )) && bindkey "${terminfo[kdch1]}" delete-char
(( ${+terminfo[kpp]} ))   && bindkey "${terminfo[kpp]}"   up-line-or-history
(( ${+terminfo[knp]} ))   && bindkey "${terminfo[knp]}"   down-line-or-history
(( ${+terminfo[khome]} )) && bindkey "${terminfo[khome]}" beginning-of-line
(( ${+terminfo[kend]} ))  && bindkey "${terminfo[kend]}"  end-of-line

# Home/End often do not correspond to terminfo;
# 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 default window title
if [[ $TERM = "xterm" || $TERM = "rxvt"  ]];then
	precmd () { print -Pn "\e]0;%n@%m: %~\a" }
fi

# 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 in /etc/profile.d/*.sh
do
	emulate -R ksh -c "source $profile_func"
done
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
