autoload -U promptinit
promptinit

# Set the prompt that I like
precmd () {
    branch=`git branch --no-color 2>/dev/null | grep \* | sed "s/^\* \(.*\)$/(${YELLOW}\1${BOLD_WHITE}) /"`

    exit="%(?..${RED}[%?]${RESET} )"

    sep="${BOLD_WHITE}%#${RESET} "

    host="${YELLOW}%m"
    user="${GREEN}%n"
    loc="${BOLD_WHITE}[$user${BOLD_WHITE}@$host${BOLD_WHITE}] "

    PS1="$loc$branch$exit$sep"
}

RPROMPT="${BOLD_WHITE}[${WHITE}%~${BOLD_WHITE}]${RESET}"

autoload -U promptinit
promptinit

parse_git_branch () {
    git branch --no-color 2>/dev/null |
        sed -e '/^[^*]/d' \
            -e "s/(detached from //" \
            -e "s/)//" \
            -e "s/* \(.*\)/${BOLD_WHITE}(${YELLOW}\1${BOLD_WHITE}) ${RESET}/"
}

# Set the prompt that I like
precmd () {
    branch=`parse_git_branch`

    exit="%(?..${RED}[%?]${RESET} )"

    sep="${BOLD_WHITE}%#${RESET} "

    host="${YELLOW}%m"
    user="${GREEN}%n"
    loc="${BOLD_WHITE}[$user${BOLD_WHITE}@$host${BOLD_WHITE}] ${RESET}"

    PS1="$loc$branch$exit$sep"
}

RPROMPT="${BOLD_WHITE}[${WHITE}%~${BOLD_WHITE}]${RESET}"

Fix git branch indicator when on detached head
Fix git branch indicator when on detached head
