dogenpunk.zsh-theme 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # -----------------------------------------------------------------------------
  2. # FILE: dogenpunk.zsh-theme
  3. # DESCRIPTION: oh-my-zsh theme file.
  4. # AUTHOR: Matthew Nelson (dogenpunk@gmail.com)
  5. # VERSION: 0.1
  6. # SCREENSHOT: coming soon
  7. # -----------------------------------------------------------------------------
  8. MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}"
  9. local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}"
  10. PROMPT='%{$fg[blue]%}%m%{$reset_color%}%{$fg_bold[white]%} ओम् %{$reset_color%}%{$fg[cyan]%}%~:%{$reset_color%}$(git_time_since_commit)$(git_prompt_info)
  11. %{$fg[red]%}%!%{$reset_color%} $(prompt_char) '
  12. ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[green]%}git%{$reset_color%}@%{$bg[white]%}%{$fg[black]%}"
  13. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
  14. ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!%{$reset_color%}"
  15. ZSH_THEME_GIT_PROMPT_CLEAN=""
  16. RPROMPT='${return_status}$(git_prompt_status)%{$reset_color%}'
  17. ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
  18. ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹"
  19. ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
  20. ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
  21. ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
  22. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
  23. function prompt_char() {
  24. git branch >/dev/null 2>/dev/null && echo "%{$fg[green]%}±%{$reset_color%}" && return
  25. hg root >/dev/null 2>/dev/null && echo "%{$fg_bold[red]%}☿%{$reset_color%}" && return
  26. echo "%{$fg[cyan]%}◯ %{$reset_color%}"
  27. }
  28. # Colors vary depending on time lapsed.
  29. ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
  30. ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
  31. ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
  32. ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
  33. # Determine the time since last commit. If branch is clean,
  34. # use a neutral color, otherwise colors will vary according to time.
  35. function git_time_since_commit() {
  36. if git rev-parse --git-dir > /dev/null 2>&1; then
  37. # Only proceed if there is actually a commit.
  38. if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
  39. # Get the last commit.
  40. last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
  41. now=`date +%s`
  42. seconds_since_last_commit=$((now-last_commit))
  43. # Totals
  44. MINUTES=$((seconds_since_last_commit / 60))
  45. HOURS=$((seconds_since_last_commit/3600))
  46. # Sub-hours and sub-minutes
  47. DAYS=$((seconds_since_last_commit / 86400))
  48. SUB_HOURS=$((HOURS % 24))
  49. SUB_MINUTES=$((MINUTES % 60))
  50. if [[ -n $(git status -s 2> /dev/null) ]]; then
  51. if [ "$MINUTES" -gt 30 ]; then
  52. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
  53. elif [ "$MINUTES" -gt 10 ]; then
  54. COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
  55. else
  56. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
  57. fi
  58. else
  59. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
  60. fi
  61. if [ "$HOURS" -gt 24 ]; then
  62. echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
  63. elif [ "$MINUTES" -gt 60 ]; then
  64. echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
  65. else
  66. echo "($COLOR${MINUTES}m%{$reset_color%}|"
  67. fi
  68. else
  69. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
  70. echo "($COLOR~|"
  71. fi
  72. fi
  73. }