wedisagree.zsh-theme 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # On a mac with snow leopard, for nicer terminal colours:
  2. # - Install SIMBL: http://www.culater.net/software/SIMBL/SIMBL.php
  3. # - Download'Terminal-Colours': http://bwaht.net/code/TerminalColours.bundle.zip
  4. # - Place that bundle in ~/Library/Application\ Support/SIMBL/Plugins (create that folder if it doesn't exist)
  5. # - Open Terminal preferences. Go to Settings -> Text -> More
  6. # - Change default colours to your liking.
  7. #
  8. # Here are the colours from Textmate's Monokai theme:
  9. #
  10. # Black: 0, 0, 0
  11. # Red: 229, 34, 34
  12. # Green: 166, 227, 45
  13. # Yellow: 252, 149, 30
  14. # Blue: 196, 141, 255
  15. # Magenta: 250, 37, 115
  16. # Cyan: 103, 217, 240
  17. # White: 242, 242, 242
  18. # Thanks to Steve Losh: http://stevelosh.com/blog/2009/03/candy-colored-terminal/
  19. # The prompt
  20. PROMPT='%{$fg[magenta]%}[%c] %{$reset_color%}'
  21. # The right-hand prompt
  22. RPROMPT='${time} %{$fg[magenta]%}$(git_prompt_info)%{$reset_color%}$(git_prompt_status)%{$reset_color%}'
  23. # Add this at the start of RPROMPT to include rvm info showing ruby-version@gemset-name
  24. # %{$fg[yellow]%}$(~/.rvm/bin/rvm-prompt)%{$reset_color%}
  25. # local time, color coded by last return code
  26. time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}"
  27. time_disabled="%{$fg[green]%}%*%{$reset_color%}"
  28. time=$time_enabled
  29. ZSH_THEME_GIT_PROMPT_PREFIX=" ☁ %{$fg[red]%}"
  30. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
  31. ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%} ☂" # Ⓓ
  32. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" # ⓣ
  33. ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ☀" # Ⓞ
  34. ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%} ✚" # ⓐ ⑃
  35. ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%} ⚡" # ⓜ ⑁
  36. ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" # ⓧ ⑂
  37. ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%} ➜" # ⓡ ⑄
  38. ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%} ♒" # ⓤ ⑊
  39. # More symbols to choose from:
  40. # ☀ ✹ ☄ ♆ ♀ ♁ ♐ ♇ ♈ ♉ ♚ ♛ ♜ ♝ ♞ ♟ ♠ ♣ ⚢ ⚲ ⚳ ⚴ ⚥ ⚤ ⚦ ⚒ ⚑ ⚐ ♺ ♻ ♼ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷
  41. # ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵ ⩶ ⨠
  42. # ⬅ ⬆ ⬇ ⬈ ⬉ ⬊ ⬋ ⬒ ⬓ ⬔ ⬕ ⬖ ⬗ ⬘ ⬙ ⬟ ⬤ 〒 ǀ ǁ ǂ ĭ Ť Ŧ
  43. # Determine if we are using a gemset.
  44. function rvm_gemset() {
  45. GEMSET=`rvm gemset list | grep '=>' | cut -b4-`
  46. if [[ -n $GEMSET ]]; then
  47. echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|"
  48. fi
  49. }
  50. # Determine the time since last commit. If branch is clean,
  51. # use a neutral color, otherwise colors will vary according to time.
  52. function git_time_since_commit() {
  53. if git rev-parse --git-dir > /dev/null 2>&1; then
  54. # Only proceed if there is actually a commit.
  55. if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
  56. # Get the last commit.
  57. last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
  58. now=`date +%s`
  59. seconds_since_last_commit=$((now-last_commit))
  60. # Totals
  61. MINUTES=$((seconds_since_last_commit / 60))
  62. HOURS=$((seconds_since_last_commit/3600))
  63. # Sub-hours and sub-minutes
  64. DAYS=$((seconds_since_last_commit / 86400))
  65. SUB_HOURS=$((HOURS % 24))
  66. SUB_MINUTES=$((MINUTES % 60))
  67. if [[ -n $(git status -s 2> /dev/null) ]]; then
  68. if [ "$MINUTES" -gt 30 ]; then
  69. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
  70. elif [ "$MINUTES" -gt 10 ]; then
  71. COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
  72. else
  73. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
  74. fi
  75. else
  76. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
  77. fi
  78. if [ "$HOURS" -gt 24 ]; then
  79. echo "($(rvm_gemset)$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
  80. elif [ "$MINUTES" -gt 60 ]; then
  81. echo "($(rvm_gemset)$COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
  82. else
  83. echo "($(rvm_gemset)$COLOR${MINUTES}m%{$reset_color%}|"
  84. fi
  85. else
  86. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
  87. echo "($(rvm_gemset)$COLOR~|"
  88. fi
  89. fi
  90. }