peepcode.zsh-theme 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #
  2. # Based on Geoffrey Grosenbach's peepcode zsh theme from
  3. # https://github.com/topfunky/zsh-simple
  4. #
  5. git_repo_path() {
  6. command git rev-parse --git-dir 2>/dev/null
  7. }
  8. git_commit_id() {
  9. command 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" != '.' && -n "$(command 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='%(?.%F{green}☺%f.%F{red}☹%f)'
  33. PROMPT='
  34. ${VIRTUAL_ENV:+"($VIRTUAL_ENV) "}%~
  35. ${smiley} '
  36. RPROMPT='%F{white} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'
  37. # Disable automatic virtualenv prompt change
  38. export VIRTUAL_ENV_DISABLE_PROMPT=1