27ff262e09aed87dfcab4110a57e8f36c669cb0d
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
2new file mode 100644
3index 0000000000000000000000000000000000000000..51f5e375ad4b459d2b853a7532f51a12919b0520
4--- /dev/null
5+++ b/themes/avit.zsh-theme
6@@ -0,0 +1,120 @@
7+#
8+# Author:: Andrew Vit (<andrew@avit.ca>)
9+#
10+# AVIT ZSH Theme
11+#
12+# Copyright 2011, Andrew Vit
13+#
14+# Licensed under the Apache License, Version 2.0 (the "License");
15+# you may not use this file except in compliance with the License.
16+# You may obtain a copy of the License at
17+#
18+# http://www.apache.org/licenses/LICENSE-2.0
19+#
20+# Unless required by applicable law or agreed to in writing, software
21+# distributed under the License is distributed on an "AS IS" BASIS,
22+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+# See the License for the specific language governing permissions and
24+# limitations under the License.
25+#
26+
27+PROMPT='
28+$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
29+▶ '
30+
31+PROMPT2='%{$fg[grey]%}◀%{$reset_color%} '
32+
33+RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
34+
35+local _current_dir="%{$fg[blue]%}%3~%{$reset_color%} "
36+local _return_status="%{$fg[red]%}%(?..⍉)%{$reset_color%}"
37+local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
38+
39+function _user_host() {
40+ if [[ -n $SSH_CONNECTION ]]; then
41+ me="%n@%m"
42+ elif [[ $LOGNAME != $USER ]]; then
43+ me="%n"
44+ fi
45+ if [[ -n $me ]]; then
46+ echo "%{$fg[cyan]%}$me%{$reset_color%}:"
47+ fi
48+}
49+
50+function _vi_status() {
51+ if {echo $fpath | grep -q "plugins/vi-mode"}; then
52+ echo "$(vi_mode_prompt_info)"
53+ fi
54+}
55+
56+function _ruby_version() {
57+ if {echo $fpath | grep -q "plugins/rvm"}; then
58+ echo "%{$fg[grey]%}$(rvm_prompt_info)%{$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 [ $hours -gt 24 ]; then
83+ commit_age="${days}d"
84+ elif [ $minutes -gt 60 ]; then
85+ commit_age="${sub_hours}h${sub_minutes}m"
86+ else
87+ commit_age="${minutes}m"
88+ fi
89+
90+ color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
91+ echo "$color$commit_age%{$reset_color%}"
92+ fi
93+ fi
94+}
95+
96+if [[ $USER == "root" ]]; then
97+ CARETCOLOR="red"
98+else
99+ CARETCOLOR="white"
100+fi
101+
102+MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
103+
104+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
105+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"