Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added sha commit printing to promt when not in any branch

  • Loading branch information...
commit b9be10763cdcf624321c439307844011c3acd624 1 parent 30ad885
@yas375 authored
Showing with 15 additions and 0 deletions.
  1. +15 −0 zsh/config
View
15 zsh/config
@@ -4,3 +4,18 @@ export PATH="$HOME/apps/bin:$PATH"
fpath=(~/.zsh/functions $fpath)
autoload -U ~/.zsh/functions/*(:t)
+
+# Git sometimes goes into a detached head state. git_prompt_info doesn't
+# return anything in this case. So wrap it in another function and check
+# for an empty string.
+function improved_git_prompt_info() {
+ if git rev-parse --git-dir > /dev/null 2>&1; then
+ if [[ -z $(git_prompt_info) ]]; then
+ echo "$ZSH_THEME_GIT_PROMPT_PREFIX%{$fg_bold[yellow]%}$(git_prompt_short_sha)%{$reset_color%}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
+ else
+ echo "$(git_prompt_info)"
+ fi
+ fi
+}
+
+PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(improved_git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
Please sign in to comment.
Something went wrong with that request. Please try again.