-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenormous.zsh-theme
67 lines (54 loc) · 1.94 KB
/
enormous.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
git_untracked_count() {
local stat="$1"
local count=$(echo $stat | grep "^??" | wc -l)
if [ $count -eq 0 ]; then return; fi
echo "%{$fg_no_bold[yellow]%}? %{$fg_bold[yellow]%}$count %{$reset_color%}"
}
git_modified_count() {
local stat="$1"
local count=$(echo $stat | grep "^.[MD]" | wc -l)
if [ $count -eq 0 ]; then return; fi
echo "%{$fg_no_bold[red]%}M %{$fg_bold[red]%}$count %{$reset_color%}"
}
git_index_count() {
local stat="$1"
local count=$(echo $stat | grep "^[AMRD]." | wc -l)
if [ $count -eq 0 ]; then return; fi
echo "%{$fg_no_bold[green]%}S %{$fg_bold[green]%}$count %{$reset_color%}"
}
git_status_count() {
local stat=$(git status --porcelain 2>/dev/null)
echo "$(git_untracked_count $stat)$(git_modified_count $stat)$(git_index_count $stat)"
}
git_behind_ahead_count() {
branch_info=$(git --no-pager branch '--format=%(if)%(HEAD)%(then)%(upstream:track)%(end)' 2>/dev/null)
behind_count=$(echo $branch_info | grep -o 'behind [0-9]\+' | grep -o '[0-9]\+')
ahead_count=$(echo $branch_info | grep -o 'ahead [0-9]\+' | grep -o '[0-9]\+')
if ! [ $behind_count ] && ! [ $ahead_count ]; then return; fi
behind=""
if [ ! -z $behind_count ] && [ $behind_count -gt 0 ]; then
behind="↓$behind_count"
fi
ahead=""
if [ ! -z $ahead_count ] && [ $ahead_count -gt 0 ]; then
ahead="↑$ahead_count"
fi
echo "%{$fg_bold[cyan]%}$behind$ahead %{$reset_color%}"
}
git_branch() {
branch_name=$(git branch 2>/dev/null | grep "^* " | cut -d' ' -f 2)
if ! [ $branch_name ]; then return; fi
echo "%{$fg[magenta]%}$branch_name "
}
current_directory() {
echo "%{$fg[green]%}%~ "
}
exit_code() {
code=$?
if [ $code -eq 0 ]; then return; fi
# A zero-width space is added to the end to ensure the new line is not trimmed
echo "❌ %{$fg[red]%}exit code $code\n"
}
PROMPT='
$(exit_code)$(current_directory)$(git_branch)$(git_behind_ahead_count)$(git_status_count)
%{$fg[white]%}ΙΧΘΥΣ %{$reset_color%}'