-
Notifications
You must be signed in to change notification settings - Fork 3
/
sugar-free.zsh-theme
64 lines (51 loc) · 2.08 KB
/
sugar-free.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
#!/usr/bin/env zsh
# ------------------------------------------------------------------------------
#
# Sugar-free - A simple and minimal theme for oh-my-zsh
#
# Based on my favorite aspects of the Pure and Candy themes,
# as well as some Git-based snippets from <https://gist.github.com/joshdick/4415470>
#
# Pure <https://github.com/sindresorhus/pure>
# Candy <https://github.com/BinaryMuse/oh-my-zsh/blob/master/themes/candy.zsh-theme>
#
# ------------------------------------------------------------------------------
# Modify the colors and symbols in these variables as desired.
GIT_PROMPT_PREFIX="%{$fg[white]%}(%{$reset_color%}"
GIT_PROMPT_SUFFIX="%{$fg[white]%})%{$reset_color%}"
# These colors match my .gitconfig:
# [color "status"]
# added = yellow
# changed = green
# untracked = cyan
GIT_PROMPT_UNTRACKED="%{$fg_bold[cyan]%}●%{$reset_color%}"
GIT_PROMPT_MODIFIED="%{$fg_bold[green]%}●%{$reset_color%}"
GIT_PROMPT_STAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
# Show Git branch/tag, or name-rev if on detached head
parse_git_branch() {
(git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null
}
# Show different symbols as appropriate for various Git repository states
parse_git_state() {
# Compose this value via multiple conditional appends.
local GIT_STATE=""
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
GIT_STATE=$GIT_STATE$GIT_PROMPT_UNTRACKED
fi
if ! git diff --quiet 2> /dev/null; then
GIT_STATE=$GIT_STATE$GIT_PROMPT_MODIFIED
fi
if ! git diff --cached --quiet 2> /dev/null; then
GIT_STATE=$GIT_STATE$GIT_PROMPT_STAGED
fi
if [[ -n $GIT_STATE ]]; then
echo "$GIT_STATE"
fi
}
# If inside a Git repository, print its branch and state
git_prompt_string() {
local git_where="$(parse_git_branch)"
[ -n "$git_where" ] && echo "$GIT_PROMPT_PREFIX%{$fg[white]%}${git_where#(refs/heads/|tags/)}$(parse_git_state)$GIT_PROMPT_SUFFIX"
}
PROMPT=$'%{$fg[blue]%}%n %{$reset_color%}%{$fg[green]%}[%~]%{$reset_color%} $(git_prompt_string) \
%{$fg[blue]%}%{$fg[blue]%}❯%{$reset_color%} '