-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzsh_fino_custom.zsh-theme
195 lines (173 loc) · 6.35 KB
/
zsh_fino_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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# -----------------------------------------------------------------------------
# Matjaž's dotfiles ZSH custom theme configuration file
#
# Copyright (c) 2015-2016, Matjaž Guštin <dev@matjaz.it> matjaz.it
# This source code form is part of the "Matjaž's dotfiles" project and is
# subject to the terms of the BSD 3-clause license as expressed in the
# LICENSE.md file found in the top-level directory of this distribution and at
# http://directory.fsf.org/wiki/License:BSD_3Clause
# -----------------------------------------------------------------------------
#
# fino-mat.zsh-theme
# Variation of the Fino theme by Matjaž <dev@matjaz.it> matjaz.it
# v1.0 2015-09-11
# - Original version
# v1.1 2016-03-18
# - Added Python Virtualenv prompt
# - Added root name customization
# - Some fixes
# v1.2 2016-08-23
# - Re-added clocks on the right prompt
# - Current system load on the right prompt
# v1.3 2017-10-22
# - Moved current directory, Git and Mercurial info to new line
# - Changed git statuses to full words for clarity
# - Simplified the clock
# - Theme code simplification
#
# Use with a dark background and 256-color terminal!
# Suggested theme: `base16 atelierforest dark`
#
# ╭──matjaz on MatBook
# ├──on git branch master, staged, modified, untracked, stashes
# ├──on hg branch default ✔
# ├──in /private/tmp/some
# ╰○ [1.41/4] [14:15:19]
#
# Borrowing shamelessly from these oh-my-zsh themes:
# bira, robbyrussel, bureau, amuse
# http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# https://github.com/tonyseek/oh-my-zsh-virtualenv-prompt
# ==========
function color_in_gray {
echo "%{$FG[245]%}$1%{$reset_color%}"
}
separator=', '
# Git prompt global variables, used also for Mercurial
# ----------------------------------------------------
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[255]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="$separator%{$fg_bold[green]%}clean%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD="$separator%{$fg[cyan]%}▴%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND="$separator%{$fg[magenta]%}▾%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STAGED="$separator%{$fg_bold[cyan]%}staged%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="$separator%{$fg_bold[yellow]%}modified%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="$separator%{$fg_bold[red]%}untracked%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIVERGED="$separator%{$fg_bold[red]%}diverged%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STASHED="$separator%{$fg[gray]%}stashes%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="$separator%{$fg_bold[red]%}unmerged%{$reset_color%}"
# Mercurial prompt variables
# --------------------------
YS_VCS_PROMPT_PREFIX=ZSH_THEME_GIT_PROMPT_PREFIX
YS_VCS_PROMPT_SUFFIX=ZSH_THEME_GIT_PROMPT_SUFFIX
YS_VCS_PROMPT_DIRTY=ZSH_THEME_GIT_PROMPT_DIRTY
YS_VCS_PROMPT_CLEAN=ZSH_THEME_GIT_PROMPT_CLEAN
function hg_branch_name_and_status_symbol
{
if [ -d '.hg' ]; then
local hg_prompt="$(hg branch 2>/dev/null) "
if [ -n "$(hg symbols 2>/dev/null)" ]
then
hg_prompt=$hg_prompt$ZSH_THEME_GIT_PROMPT_DIRTY
else
hg_prompt=$hg_prompt$ZSH_THEME_GIT_PROMPT_CLEAN
fi
hg_prompt=$hg_prompt$ZSH_THEME_GIT_PROMPT_SUFFIX
echo "\n├──$(color_in_gray 'on hg branch') $hg_prompt"
fi
}
function git_status_symbols {
index=$(command git status --porcelain --branch 2> /dev/null)
local symbols=""
if $(git diff-index --quiet HEAD -- 2> /dev/null)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
if $(echo "$index" | grep '^## .*ahead' &> /dev/null)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
if $(echo "$index" | grep '^## .*behind' &> /dev/null)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
if $(echo "$index" | grep '^## .*diverged' &> /dev/null)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi
if $(echo "$index" | grep '^UU ' &> /dev/null)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
if $(echo "$index" | grep '^[AMRD]. ' &> /dev/null)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_STAGED"
fi
if $(echo "$index" | grep '^.[MTD] ' &> /dev/null)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
if $(echo "$index" | command grep -E '^\?\? ' &> /dev/null)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1)
then
symbols="$symbols$ZSH_THEME_GIT_PROMPT_STASHED"
fi
echo $symbols
}
function git_branch_name_and_status_symbol
{
if [ -d '.git' ]
then
local git_branch="$(git symbolic-ref --short HEAD 2> /dev/null)"
echo "\n├──$(color_in_gray 'on git branch') $git_branch$(git_status_symbols)$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
}
function host_name_prompt {
echo "$(color_in_gray 'on') %{$FG[033]%}${SHORT_HOST:-$HOST}%{$reset_color%}"
}
function root_or_user_name_prompt
{
if [[ $UID -eq 0 ]]
then
echo "%{$FG[202]%}r☢☢t%{$reset_color%}"
else
echo "%{$FG[040]%}%n%{$reset_color%}"
fi
}
function current_virtualenv_prompt
{
if [ -n "$VIRTUAL_ENV" ]
then
if [ -f "$VIRTUAL_ENV/__name__" ]; then
local name=$(<$VIRTUAL_ENV/__name__)
elif [ `basename $VIRTUAL_ENV` = "__" ]; then
local name=$(basename $(dirname $VIRTUAL_ENV))
else
local name=$(basename $VIRTUAL_ENV)
fi
echo "$(color_in_gray 'within') $name"
fi
}
function current_time
{
string="[$(date '+%H:%M:%S')]"
echo "$(color_in_gray $string)"
}
function current_system_load
{
# Avoiding index-based cuts so it works with BSD uptime and GNU uptime
color_in_gray "[$(uptime | sed -E 's/.* ([0-9]+.[0-9]+),? [0-9]+.[0-9]+,? [0-9]+.[0-9]+$/\1/')/$(getconf _NPROCESSORS_ONLN)]"
}
function current_dir
{
echo "$(color_in_gray 'in') %{$terminfo[bold]$FG[226]%}${PWD/#$HOME/~}%{$reset_color%}"
}
PROMPT='
╭──$(root_or_user_name_prompt) $(host_name_prompt) $(git_branch_name_and_status_symbol) $(hg_branch_name_and_status_symbol) $(current_virtualenv_prompt)
├──$(current_dir)
╰○ '
RPROMPT='$(current_system_load) $(current_time)'