Skip to content

Instantly share code, notes, and snippets.

@rightson
Created June 10, 2017 23:03
Show Gist options
  • Save rightson/aa7da94fd7735accec95372ed36bb3a6 to your computer and use it in GitHub Desktop.
Save rightson/aa7da94fd7735accec95372ed36bb3a6 to your computer and use it in GitHub Desktop.
# from https://stackoverflow.com/questions/1128496/to-get-a-prompt-which-indicates-git-branch-in-zsh
# get the name of the branch we are on
git_prompt_info() {
git branch | awk '/^\*/ { print $2 }'
}
get_git_dirty() {
git diff --quiet || echo '*'
}
autoload -U colors
colors
setopt prompt_subst
PROMPT='%{$fg[blue]%}%c %{$fg_bold[red]%}$(git_prompt_info)$(get_git_dirty)%{$fg[blue]%} $ %{$reset_color%}'
RPROMPT='%{$fg[green]%}%1(j.%j.)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment