# This zsh function is called whenever changing directories and
# shows the current git branch in the prompt
function precmd()
{
    # Adjust this to your current preferred prompt
    PROMPT="-`hostname`- %n %T %~"
    local _git _branch

    # This call requires the "findup" script from http://www.davidfaure.fr/scripts
    _git=`findup .git`

    if test -n "$_git"; then
        _branch=`sed -e 's,.*/,,' $_git/HEAD`
        PROMPT="$PROMPT ($_branch)"
    fi

    # Alternative solution, from Mike Arthur: something like:
    # BRANCH_REFS=$(git symbolic-ref HEAD 2>/dev/null); PROMPT="$PROMPT (${BRANCH_REFS#refs/heads/})"

    # Add final character after the optional git branch (usually # or >)
    export PROMPT="$PROMPT>"
}
