-
Notifications
You must be signed in to change notification settings - Fork 1
/
yellow-sea-diamonds.zsh-theme
77 lines (60 loc) · 3.1 KB
/
yellow-sea-diamonds.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
# yellow-sea-diamonds.zsh-theme
# https://github.com/jimratliff/yellow-sea-diamonds-zsh-theme
# REPORT VIRTUAL ENVIRONMENT
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`')'
}
VIRTUALENV_REPORT=$FG[040]\$(virtualenv_info)%f
# REPORT CURRENT WORKING DIRECTORY (CWD)
# Explanation of: %0~
# If the CWD starts with $HOME, that part is replaced by “~”. Furthermore, if it has a named directory as its prefix,
# that part is replaced by “~” followed by the name of the directory, but only is the result is shorter than the full
# path.
CWD_BASE="%0~"
CWD=$FG[226]$CWD_BASE%f
# REPORT GIT BRANCH, STATUS, COMMIT, ETC>
# $(git_prompt_info) is a function built into Oh My Zsh which displays the current branch name.
# It also returns the following, which can be customized.
# Prepended to the beginning of the git info
ZSH_THEME_GIT_PROMPT_PREFIX=" $FG[250]| git:%f $FG[135]"
# Conditionally returned if there are any uncommitted changes on your branch
# Returns a ❌ if there are uncommitted changes
ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%} ✘%f"
# Conditionally returned if there are no uncommitted changes on your branch
# Returns a ✅ if the are no uncommitted changes on your branch
ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%} ✔%f"
# Although ZSH_THEME_GIT_PROMPT_SUFFIX is often used as the vehicle for displaying the commit hash, I ran into
# a problem I wasn't able to solve when using ZSH_THEME_GIT_PROMPT_SUFFIX for that purpose: the commit hash
# wouldn't update automatically. (This typically has something to do with double quotes vs. single quotes, and
# the fix is using single quotes to delay evaluation.)
# However, by appending it to the prompt myself, I don't have that problem.
# The limitation that creates (as least as of the current state) is that I can't wrap the commit hash in
# delimiters, because those delimiters would display even when there is no commit hash.
# I need to set ZSH_THEME_GIT_PROMPT_SUFFIX to an empty string to prevent a default suffix from appearing.
ZSH_THEME_GIT_PROMPT_SUFFIX=""
GIT_REPORT=$FG[033]\$(git_prompt_info)%f
# Appended to the end of git info
# Appends the hash of the commit
COMMIT_HASH='$FG[033]$(git_prompt_short_sha)%f'
# REPORT RETURN CODE
# The following expression:
# %(?.$NOERROR.$ERROR_OCCURRED)
# is a ternary conditional, which shows the second argument ($NOERROR) if the condition is true, and show the third
# argument if the condition is false.
# The condition (%?) is the return code. (Zero is true in Zsh.)
# Displays $NOERROR if previous command exited normally
# Displays $ERROR_OCCURRED otherwise
# My personal preference: Display nothing if there was no error. A lack of error isn’t sufficiently informative to
# warrant the additional visual noise.
NOERROR=""
# NOERROR="✅"
# Displays "ERROR n" in White on Red background
ERROR_OCCURRED="$BG[001]$FG[255]ERROR #%?%f%k"
REPORT_RETURN_CODE="%(?.$NOERROR.$ERROR_OCCURRED)"
function prompt_char {
echo ' 🔶' && return
}
# NOW CONSTRUCT THE PROMPT
PROMPT="
╭─$VIRTUALENV_REPORT $CWD $GIT_REPORT $COMMIT_HASH %{$reset_color%}
╰─$REPORT_RETURN_CODE\$(prompt_char) "