wedisagree.zsh-theme 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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%}$(git_prompt_ahead)%{$reset_color%}'
  23. # Add this at the start of RPROMPT to include rvm info showing ruby-version@gemset-name
  24. # $(ruby_prompt_info)
  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. ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[blue]%} 𝝙"
  40. ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[yellow]%}"
  41. ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
  42. # More symbols to choose from:
  43. # ☀ ✹ ☄ ♆ ♀ ♁ ♐ ♇ ♈ ♉ ♚ ♛ ♜ ♝ ♞ ♟ ♠ ♣ ⚢ ⚲ ⚳ ⚴ ⚥ ⚤ ⚦ ⚒ ⚑ ⚐ ♺ ♻ ♼ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷
  44. # ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵ ⩶ ⨠
  45. # ⬅ ⬆ ⬇ ⬈ ⬉ ⬊ ⬋ ⬒ ⬓ ⬔ ⬕ ⬖ ⬗ ⬘ ⬙ ⬟ ⬤ 〒 ǀ ǁ ǂ ĭ Ť Ŧ
  46. # Determine if we are using a gemset.
  47. function rvm_gemset() {
  48. GEMSET=`rvm gemset list | grep '=>' | cut -b4-`
  49. if [[ -n $GEMSET ]]; then
  50. echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|"
  51. fi
  52. }
  53. # Determine the time since last commit. If branch is clean,
  54. # use a neutral color, otherwise colors will vary according to time.
  55. function git_time_since_commit() {
  56. if git rev-parse --git-dir > /dev/null 2>&1; then
  57. # Only proceed if there is actually a commit.
  58. if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then
  59. now=`date +%s`
  60. seconds_since_last_commit=$((now-last_commit))
  61. # Totals
  62. MINUTES=$((seconds_since_last_commit / 60))
  63. HOURS=$((seconds_since_last_commit/3600))
  64. # Sub-hours and sub-minutes
  65. DAYS=$((seconds_since_last_commit / 86400))
  66. SUB_HOURS=$((HOURS % 24))
  67. SUB_MINUTES=$((MINUTES % 60))
  68. if [[ -n $(git status -s 2> /dev/null) ]]; then
  69. if [ "$MINUTES" -gt 30 ]; then
  70. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
  71. elif [ "$MINUTES" -gt 10 ]; then
  72. COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
  73. else
  74. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
  75. fi
  76. else
  77. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
  78. fi
  79. if [ "$HOURS" -gt 24 ]; then
  80. echo "($(rvm_gemset)$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
  81. elif [ "$MINUTES" -gt 60 ]; then
  82. echo "($(rvm_gemset)$COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
  83. else
  84. echo "($(rvm_gemset)$COLOR${MINUTES}m%{$reset_color%}|"
  85. fi
  86. else
  87. COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
  88. echo "($(rvm_gemset)$COLOR~|"
  89. fi
  90. fi
  91. }