-
Notifications
You must be signed in to change notification settings - Fork 1
/
joni-two.zsh-theme
65 lines (53 loc) · 2.05 KB
/
joni-two.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
function kube_prompt() {
if [ ! -f "Jenkinsfile" ]; then
return
fi
context=$(kubectl config current-context 2> /dev/null) || return
echo "%{$reset_color%} ‹k8s in %{$fg[yellow]%}${context}%{$reset_color%}›"
}
function git_prompt_check() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "%{$reset_color%} at %{$fg[magenta]%}${ref#refs/heads/}"
if [ ! -f ".git/FETCH_HEAD" ]; then
return
fi
# On mac do git fetch automatically if not done in the last 24h
if [[ `uname` == 'Darwin' ]]; then
last_fetch=$(stat -f "%Sm" -t "%s" .git/FETCH_HEAD)
time_now=$(date +%s)
time_diff=$((($time_now-$last_fetch) / 60 / 60))
if [ $time_diff -gt 24 ]; then
git fetch
git remote prune origin > /dev/null
fi
fi
}
git_remote_check() {
remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l | xargs)
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l | xargs)
if [ $ahead -eq 0 ] && [ $behind -gt 0 ]
then
echo "%{$reset_color%} $behind↓"
elif [ $ahead -gt 0 ] && [ $behind -eq 0 ]
then
echo "%{$reset_color%} $ahead↑"
elif [ $ahead -gt 0 ] && [ $behind -gt 0 ]
then
echo "%{$reset_color%} $ahead↑$behind↓"
fi
fi
}
NAME="%{$fg[magenta]%}%n"
MACHINE="%{$fg[yellow]%}$(scutil --get ComputerName)"
DIR="%{$fg[green]%}%~%"
PROMPT='$NAME %{$reset_color%}on $MACHINE %{$reset_color%}in $DIR $(git_prompt_check)$(git_prompt_status)$(git_remote_check)
%{$fg[cyan]%}$ %{$reset_color%}'
RPROMPT=''
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%} ✈"
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[magenta]%} ✂"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%} ✱"