peepcode.zsh-theme 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #
  2. # Based on Geoffrey Grosenbach's peepcode zsh theme from
  3. # https://github.com/topfunky/zsh-simple
  4. #
  5. git_repo_path() {
  6. git rev-parse --git-dir 2>/dev/null
  7. }
  8. git_commit_id() {
  9. git rev-parse --short HEAD 2>/dev/null
  10. }
  11. git_mode() {
  12. if [[ -e "$repo_path/BISECT_LOG" ]]; then
  13. echo "+bisect"
  14. elif [[ -e "$repo_path/MERGE_HEAD" ]]; then
  15. echo "+merge"
  16. elif [[ -e "$repo_path/rebase" || -e "$repo_path/rebase-apply" || -e "$repo_path/rebase-merge" || -e "$repo_path/../.dotest" ]]; then
  17. echo "+rebase"
  18. fi
  19. }
  20. git_dirty() {
  21. if [[ "$repo_path" != '.' && `git ls-files -m` != "" ]]; then
  22. echo " %{$fg_bold[grey]%}✗%{$reset_color%}"
  23. fi
  24. }
  25. git_prompt() {
  26. local cb=$(git_current_branch)
  27. if [ -n "$cb" ]; then
  28. local repo_path=$(git_repo_path)
  29. echo " %{$fg_bold[grey]%}$cb %{$fg[white]%}$(git_commit_id)%{$reset_color%}$(git_mode)$(git_dirty)"
  30. fi
  31. }
  32. local smiley="%(?,%{$fg[green]%}☺%{$reset_color%},%{$fg[red]%}☹%{$reset_color%})"
  33. PROMPT='
  34. %~
  35. ${smiley} %{$reset_color%}'
  36. RPROMPT='%{$fg[white]%} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'