-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoonbloom.zsh-theme
92 lines (77 loc) · 2.33 KB
/
moonbloom.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
# Moonbloom theme for Zsh
#
# Github: https://github.com/moonbloom-theme/zsh
# Website: https://moonbloom.teplostanski.dev
#
# Copyright 2024, All rights reserved
# Code licensed under the MIT license
#
# @author Igor Teplostanski <[email protected]>
# @maintainer Igor Teplostanski <[email protected]>
# Resolve the current path with special handling for root and home directories
process_path() {
local full_path="$1"
# Root directory: no further processing needed
if [[ "$full_path" == "/" ]]; then
echo "/"
return
fi
# Home directory: show as ~
if [[ "$full_path" == "$HOME" ]]; then
echo "~"
return
fi
# Paths under home: replace $HOME with ~
if [[ "$full_path" == "$HOME/"* ]]; then
echo "~${full_path#$HOME}"
return
fi
# Ensure absolute paths retain the leading slash
if [[ "$full_path" == /* ]]; then
echo "$full_path"
return
fi
}
# Apply color highlighting to the processed path
colorize_path() {
local processed_path="$1"
# Split the path into parent (tail) and current directory
local current_dir="${processed_path##*/}"
local parent_path="${processed_path%/*}"
# Special cases: root and home directories
if [[ "$processed_path" == "/" ]]; then
echo "%F{blue}/%f"
elif [[ "$processed_path" == "~" ]]; then
echo "%F{blue}~%f"
else
# General case: parent is white, current directory is blue
echo "%F{white}${parent_path}/%F{blue}${current_dir}%f"
fi
}
# Generate the custom prompt path with colors
custom_prompt_path() {
local processed_path
processed_path="$(process_path "$PWD")"
colorize_path "$processed_path"
}
PS1='$(custom_prompt_path)$(git_prompt_info) %F{magenta}%(!.#.>)%f '
# Secondary prompt
PS2="%F{red}\\ %f"
# Right prompt: return code and virtualenv
RPS1="%(?..%F{red}%? ↵%f)"
if (( $+functions[virtualenv_prompt_info] )); then
RPS1+='$(virtualenv_prompt_info)'
fi
# Git settings
ZSH_THEME_GIT_PROMPT_PREFIX=" %B%F{cyan}[%b%F{green}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="%B%F{yellow}%b*%f"
ZSH_THEME_GIT_PROMPT_SUFFIX="%B%F{cyan}]%b%f"
# Hg settings
ZSH_THEME_HG_PROMPT_PREFIX=" %B%F{cyan}[%b%F{green}"
ZSH_THEME_HG_PROMPT_CLEAN=""
ZSH_THEME_HG_PROMPT_DIRTY="%B%F{yellow}%b*%f"
ZSH_THEME_HG_PROMPT_SUFFIX="%B%F{cyan}]%b%f"
# Virtualenv settings
ZSH_THEME_VIRTUALENV_PREFIX=" %F{cyan}{"
ZSH_THEME_VIRTUALENV_SUFFIX="}%f"