-
Notifications
You must be signed in to change notification settings - Fork 0
/
ducky.zsh-theme
66 lines (52 loc) · 1.55 KB
/
ducky.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
###################
# BUILDING PROMPT #
###################
# username --> %n
# machine name --> %m
# current location --> %~
# Main prompt (left)
PROMPT='$fg[yellow] _
__(.)$fg[red]<$fg[white] ╭─$(nvm_prompt_info) $fg[yellow]$(get_pwd)%b$(check_git_prompt_info)
$fg[yellow]\___)$fg[white] ╰───>> '
RPROMPT=''
######################
# Git Prompt Builder #
######################
ZSH_THEME_GIT_PROMPT_PREFIX="-["
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[white]%}]"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%} ✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ✔"
# Git sometimes goes into a detached head state. git_prompt_info doesn't
# return anything in this case. So wrap it in another function and check
# for an empty string.
function check_git_prompt_info() {
if git rev-parse --git-dir > /dev/null 2>&1; then
if [[ -z $(git_prompt_info) ]]; then
echo "%{$fg[magenta]%}detached-head%{$reset_color%})"
else
echo "$(git_prompt_info)"
fi
fi
}
######################
# NVM Prompt Builder #
######################
ZSH_THEME_NVM_PROMPT_PREFIX="%{$fg[green]%}⬡ %{$fg[white]%}"
ZSH_THEME_NVM_PROMPT_SUFFIX="%{$fg[white]%}"
########################
# Location Path Setter #
########################
function get_pwd(){
git_root=$PWD
while [[ $git_root != / && ! -e $git_root/.git ]]; do
git_root=$git_root:h
done
if [[ $git_root = / ]]; then
unset git_root
prompt_short_dir=%~
else
parent=${git_root%\/*}
prompt_short_dir=${PWD#$parent/}
fi
echo $prompt_short_dir
}