-
Notifications
You must be signed in to change notification settings - Fork 5
/
itg.red.zsh-theme
135 lines (114 loc) · 3.29 KB
/
itg.red.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# itg.zsh-theme
# a designer developed zsh Prompt
# twitter: @itg
# https://github.com/itsthatguy/itg.zsh-theme
# Colors:
local black=235
local dark=008
local white=015
local yellow=003
local blue=038
local darker_blue=030
local darker_green=023
local red=160
local darker_red=124
local darkest_red=88
# COLOR LOVE
echo "REDEFINING COLORS"
printf '\e]4;160;rgb:F3/56/56\e\\\e[38;5;160m██ = RED\e[m\n'
printf '\e]4;124;rgb:CA/40/40\e\\\e[38;5;124m██ = DARKER_RED\e[m\n'
printf '\e]4;88;rgb:98/37/37\e\\\e[38;5;88m██ = DARKEST_RED\e[m\n'
# Extending the git library locally
function git_user_initials {
MSG=$(git config --get user.initials || echo '✈')
print $MSG
}
function git_is_dirty() {
local SUBMODULE_SYNTAX=''
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
fi
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
return 0
else
return 1
fi
}
function itg_git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(itg_git_prompt_ahead)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
function itg_git_prompt_ahead() {
if $(echo "$(git log $(itg_git_current_upstream)/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
}
function itg_git_current_upstream() {
local upstream=$(git config --get branch."$(current_branch)".remote) || return
echo $upstream
}
# Prompt builder functions
function itg_dir() {
if git rev-parse --git-dir > /dev/null 2>&1 && [ ! -d .git ]; then
git_dir_cdup=$(git rev-parse --show-cdup)
git_dir_top=$(cd $git_dir_cdup; echo ${PWD##*/})
git_dir_path=$(git rev-parse --show-prefix)
dir="⭠ $git_dir_top/$git_dir_path"
else
if [ -d .git ]; then
prefix="⭠ "
else
prefix=""
fi
dir="$prefix%1~"
fi
echo -n "%K{$red} %F{$black}$dir"
}
function itg_git() {
# Is this a dirty git directory?
# This check is done first to set colors
if ($(git_is_dirty)); then
git_status_color_k=$yellow
git_status_color_f=$darkest_red
else
git_status_color_k=$darker_red
git_status_color_f=$black
fi
# Is this a git directory?
if git rev-parse --git-dir > /dev/null 2>&1; then
git_prefix=" %K{$git_status_color_k}%F{$red}⮀ %F{$git_status_color_f}"
git_suffix="%F{$git_status_color_k}⮀"
git_status=$(itg_git_prompt_info)
else
git_prefix=""
git_suffix="%F{$red}⮀"
git_status=""
fi
echo -e "$git_prefix$git_status %K{$darkest_red}$git_suffix"
}
function itg_pair() {
echo " %F{$yellow}$(git_user_initials) %k%F{$darkest_red}⮀%f"
}
function itg_rvm() {
echo -e "%F{$dark}⮂%K{$dark}%F{$white} $(rvm_prompt_info) %k"
}
function itg_wrap_right() {
echo -e "%F{$dark}⮂%K{$dark}%F{$white} $* %k"
}
function itg_host() {
item=$(itg_wrap_right %m)
echo -e "${item}"
}
ZSH_THEME_GIT_PROMPT_PREFIX=''
ZSH_THEME_GIT_PROMPT_SUFFIX=''
ZSH_THEME_GIT_PROMPT_DIRTY='%F{$darkest_red} ✍'
ZSH_THEME_GIT_PROMPT_CLEAN=''
ZSH_THEME_GIT_PROMPT_AHEAD="↑"
ZSH_THEME_GIT_PROMPT_BEHIND="↓"
ZSH_THEME_GIT_PROMPT_DIVERGED="↕"
# command to make sure the prompt reruns the functions on new prompt
function precmd {
PROMPT="
$(itg_dir)$(itg_git)$(itg_pair) "
RPROMPT="$(itg_host)"
}