#
# Use the user zsh configuration as root
#

if [[ "$SUDO_USER" ]] && [[ "$UID" = 0 ]]; then
    # define root history path
    export HISTFILE="$ZSHDOTDIR/history/history_root"
    if [[ -f ~/.zcompdump ]]; then
        # ugly hack : reset some file perms to normal to avoid warnings
        chmod 0644 ~/.zcompdump
        chown "$SUDO_USER:$SUDO_USER" ~/.zcompdump
    fi
fi