Browse code

Merge pull request #412 from transat/master

Added git-friendly 'wedisagree' theme.

Robby Russell authored on 23/07/2011 at 16:03:15
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,107 @@
0
+# On a mac with snow leopard, for nicer terminal colours:
1
+
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
+
19
+# Thanks to Steve Losh: http://stevelosh.com/blog/2009/03/candy-colored-terminal/
20
+
21
+# The prompt
22
+
23
+PROMPT='%{$fg[magenta]%}[%c] %{$reset_color%}'
24
+
25
+# The right-hand prompt
26
+
27
+RPROMPT='${time} %{$fg[magenta]%}$(git_prompt_info)%{$reset_color%}$(git_prompt_status)%{$reset_color%}'
28
+
29
+# Add this at the start of RPROMPT to include rvm info showing ruby-version@gemset-name
30
+# %{$fg[yellow]%}$(~/.rvm/bin/rvm-prompt)%{$reset_color%} 
31
+
32
+# local time, color coded by last return code
33
+time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}"
34
+time_disabled="%{$fg[green]%}%*%{$reset_color%}"
35
+time=$time_enabled
36
+
37
+ZSH_THEME_GIT_PROMPT_PREFIX=" ☁  %{$fg[red]%}"
38
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
39
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%} ☂" # Ⓓ
40
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" # ⓣ
41
+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ☀" # Ⓞ
42
+
43
+ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%} ✚" # ⓐ ⑃
44
+ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%} ⚡"  # ⓜ ⑁
45
+ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" # ⓧ ⑂
46
+ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%} ➜" # ⓡ ⑄
47
+ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%} ♒" # ⓤ ⑊
48
+
49
+# More symbols to choose from:
50
+# ☀ ✹ ☄ ♆ ♀ ♁ ♐ ♇ ♈ ♉ ♚ ♛ ♜ ♝ ♞ ♟ ♠ ♣ ⚢ ⚲ ⚳ ⚴ ⚥ ⚤ ⚦ ⚒ ⚑ ⚐ ♺ ♻ ♼ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷
51
+# ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵  ⩶ ⨠ 
52
+# ⬅ ⬆ ⬇ ⬈ ⬉ ⬊ ⬋ ⬒ ⬓ ⬔ ⬕ ⬖ ⬗ ⬘ ⬙ ⬟  ⬤ 〒 ǀ ǁ ǂ ĭ Ť Ŧ
53
+
54
+# Determine if we are using a gemset.
55
+function rvm_gemset() {
56
+    GEMSET=`rvm gemset list | grep '=>' | cut -b4-`
57
+    if [[ -n $GEMSET ]]; then
58
+        echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|"
59
+    fi 
60
+}
61
+
62
+# Determine the time since last commit. If branch is clean,
63
+# use a neutral color, otherwise colors will vary according to time.
64
+function git_time_since_commit() {
65
+    if git rev-parse --git-dir > /dev/null 2>&1; then
66
+        # Only proceed if there is actually a commit.
67
+        if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
68
+            # Get the last commit.
69
+            last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
70
+            now=`date +%s`
71
+            seconds_since_last_commit=$((now-last_commit))
72
+
73
+            # Totals
74
+            MINUTES=$((seconds_since_last_commit / 60))
75
+            HOURS=$((seconds_since_last_commit/3600))
76
+           
77
+            # Sub-hours and sub-minutes
78
+            DAYS=$((seconds_since_last_commit / 86400))
79
+            SUB_HOURS=$((HOURS % 24))
80
+            SUB_MINUTES=$((MINUTES % 60))
81
+            
82
+            if [[ -n $(git status -s 2> /dev/null) ]]; then
83
+                if [ "$MINUTES" -gt 30 ]; then
84
+                    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
85
+                elif [ "$MINUTES" -gt 10 ]; then
86
+                    COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
87
+                else
88
+                    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
89
+                fi
90
+            else
91
+                COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
92
+            fi
93
+
94
+            if [ "$HOURS" -gt 24 ]; then
95
+                echo "($(rvm_gemset)$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
96
+            elif [ "$MINUTES" -gt 60 ]; then
97
+                echo "($(rvm_gemset)$COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
98
+            else
99
+                echo "($(rvm_gemset)$COLOR${MINUTES}m%{$reset_color%}|"
100
+            fi
101
+        else
102
+            COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
103
+            echo "($(rvm_gemset)$COLOR~|"
104
+        fi
105
+    fi
106
+}
0 107
\ No newline at end of file