dogenpunk.zsh-theme 3.2 KB

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