title: To get a prompt which indicates Git-branch in Zsh
body: <p>I run the following codes separately as my prompt unsuccessfully in .zshrc. This suggests me that apparently I do not have a program called __git_ps1. It is not in MacPorts.</p>
  
  <h2>#1</h2>
  
  <pre><code>PROMPT="$(__git_ps1 " \[\033[1;32m\] (%s)\[\033[0m\]")\$"$
  </code></pre>
  
  <h2>#2</h2>
  
  <pre><code>PROMPT="$(__git_ps1 " (%s)")\$"$
  </code></pre>
  
  <h2><a href="http://pastie.org/325104" rel="noreferrer">#3</a></h2>
  
  <pre><code># Get the name of the branch we are on
  git_prompt_info() {
    branch_prompt=$(__git_ps1)
    if [ -n "$branch_prompt" ]; then
      status_icon=$(git_status)
      echo $branch_prompt $status_icon
    fi
  }
  
  # Show character if changes are pending
  git_status() {
    if current_git_status=$(git status | grep 'added to commit' 2&gt; /dev/null); then
      echo "☠"
    fi
  }
  autoload -U colors
  colors
  setopt prompt_subst
  PROMPT='
  %~%{$fg_bold[black]%}$(git_prompt_info)
  → %{$reset_color%}'
  </code></pre>
  
  <p><strong>How can you get a prompt which shows the name of a Git-branch?</strong></p>