Um eine Eingabeaufforderung zu erhalten, die Git-branch in Zsh anzeigt

Ich führe die folgenden Codes separat aus, da meine Aufforderung in .zshrc nicht erfolgreich war. Dies legt nahe, dass ich anscheinend kein Programm namens __git_ps1 habe. Es ist nicht in MacPorts.

# 1
PROMPT="$(__git_ps1 " \[\033[1;32m\] (%s)\[\033[0m\]")\$"$
# 2
PROMPT="$(__git_ps1 " (%s)")\$"$
#3
# 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> /dev/null); then
    echo "☠"
  fi
}
autoload -U colors
colors
setopt prompt_subst
PROMPT='
%~%{$fg_bold[black]%}$(git_prompt_info)
→ %{$reset_color%}'

Wie kann man eine Eingabeaufforderung bekommen, die den Namen eines Git-Zweigs anzeigt?

Antworten auf die Frage(5)

Ihre Antwort auf die Frage