-
Notifications
You must be signed in to change notification settings - Fork 1
/
custom.zsh-theme
109 lines (89 loc) · 3.33 KB
/
custom.zsh-theme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# AVIT ZSH Theme
PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}$TIME%{$(echotc DO 1)%}'
local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
function _current_dir() {
local _max_pwd_length="65"
if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then
echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} "
else
echo "%{$fg_bold[blue]%}%~%{$reset_color%} "
fi
}
function _user_host() {
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
elif [[ $LOGNAME != $USER ]]; then
me="%n"
fi
if [[ -n $me ]]; then
echo "%{$fg[cyan]%}$me%{$reset_color%}:"
fi
}
function _vi_status() {
if {echo $fpath | grep -q "plugins/vi-mode"}; then
echo "$(vi_mode_prompt_info)"
fi
}
function _ruby_version() {
if {echo $fpath | grep -q "plugins/rvm"}; then
echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
elif {echo $fpath | grep -q "plugins/rbenv"}; then
echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}"
fi
}
# Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time.
function _git_time_since_commit() {
# Only proceed if there is actually a commit.
if git log -1 > /dev/null 2>&1; then
# Get the last commit.
last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
now=$(date +%s)
seconds_since_last_commit=$((now-last_commit))
# Totals
minutes=$((seconds_since_last_commit / 60))
hours=$((seconds_since_last_commit/3600))
# Sub-hours and sub-minutes
days=$((seconds_since_last_commit / 86400))
sub_hours=$((hours % 24))
sub_minutes=$((minutes % 60))
if [ $hours -gt 24 ]; then
commit_age="${days}d"
elif [ $minutes -gt 60 ]; then
commit_age="${sub_hours}h${sub_minutes}m"
else
commit_age="${minutes}m"
fi
color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
echo "$color$commit_age%{$reset_color%}"
fi
}
if [[ $USER == "root" ]]; then
CARETCOLOR="red"
else
CARETCOLOR="white"
fi
MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ "
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ "
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
# Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}"
# Grab the current date (%W) and time (%t):
TIME="%{$fg_bold[grey]%}[ %{$fg_bold[yellow]%}%D{%y/%m/%f}%{$reset_color%} %{$fg_bold[white]%}%* %{$fg_bold[grey]%}] %{$reset_color%}"