-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.zshrc
More file actions
158 lines (135 loc) · 3.13 KB
/
.zshrc
File metadata and controls
158 lines (135 loc) · 3.13 KB
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
# Make sure autocomplete works properly
autoload -Uz compinit
compinit
# Load colors
autoload -Uz colors && colors
setopt prompt_subst
# Git branch info setup
autoload -Uz vcs_info
precmd() { vcs_info }
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git:*' formats ' %b'
ROSEWATER='%F{#f5e0dc}'
MAUVE='%F{#cba6f7}'
TEAL='%F{#94e2d5}'
PEACH='%F{#fab387}'
SOFT_GRAY='%F{#6c7086}'
RESET='%f%k'
BUBBLE_BG='%{%K{#f5e0dc}%}'
BUBBLE_FG='%{%F{#1e1e2e}%}'
function kube_prompt() {
local context=$(kubectl config current-context 2>/dev/null)
if [ -n "$context" ]; then
echo "(k8s:$context)"
fi
}
function pretty_git() {
# Don't forget the space at the end of the echo
[[ -n "${vcs_info_msg_0_}" ]] && echo "${vcs_info_msg_0_} "
}
# Custom function to show 🏡 if in home
function pretty_pwd() {
case "$PWD" in
"$HOME")
echo "🏡"
;;
"$HOME/Documents")
echo "📄"
;;
"$HOME/Downloads")
echo "📁"
;;
"$HOME/Pictures")
echo "🖼️"
;;
"$HOME/Music")
echo "🎵"
;;
"$HOME/Desktop")
echo "🖥️"
;;
"$HOME/workspace")
echo "💻"
;;
*)
echo "%~"
;;
esac
#if [[ "$PWD" == "$HOME" ]]; then
# echo "🏡"
#else
# echo "%~"
#fi
}
# Dynamic time color based on hour
function dynamic_time_prompt() {
local hour=$(date +%H)
local color icon
if (( hour >= 6 && hour < 12 )); then
color=$PEACH
icon='☀️'
elif (( hour >= 12 && hour < 18 )); then
color=$TEAL
icon='☀️'
elif (( hour >= 18 && hour < 21 )); then
color=$MAUVE
icon='🌙'
else
color=$SOFT_GRAY
icon='🌙'
fi
echo "%{$color%}%*%{$RESET%}"
}
function build_prompt() {
local GIT_INFO="$(pretty_git)"
local PWD_INFO="$(pretty_pwd)"
PROMPT="⭐ ${MAUVE}[${ROSEWATER}%n${MAUVE}@${TEAL}${PWD_INFO}${MAUVE}] ${PEACH}${GIT_INFO}${RESET}➔ "
}
precmd_functions+=(build_prompt)
function build_rprompt() {
RPROMPT="$(dynamic_time_prompt)"
}
precmd_functions+=(build_rprompt)
source ~/.gnu_aliases
# Soft pastel fzf colors
export FZF_DEFAULT_OPTS="
--color=fg:#cdd6f4,bg:#1e1e2e,hl:#f38ba8
--color=fg+:#f5e0dc,bg+:#313244,hl+:#fab387
--color=info:#89b4fa,prompt:#94e2d5,pointer:#f5c2e7
--color=marker:#a6e3a1,spinner:#b4befe,header:#cba6f7
--layout=reverse
--border
"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Load custom shell functions
for f in ~/.config/shell-functions/*.sh; do
source "$f"
done
function kctx() {
local selected
selected=$(kubectl config get-contexts -o name | \
fzf --prompt="Select context > " \
--height=40% \
--layout=reverse \
--border \
--ansi)
if [[ -n "$selected" ]]; then
kubectl config use-context "$selected"
else
echo "No context selected."
fi
}
function git-ch() {
local branch
branch=$(git branch --sort=-committerdate | sed 's/* //' | sed 's/^[[:space:]]*//' | \
fzf --prompt="Checkout branch > " \
--height=40% \
--layout=reverse \
--border)
if [[ -n "$branch" ]]; then
git checkout "$branch"
fi
}
alias kc=kctx
alias gch="git-ch"
export PATH="/opt/homebrew/bin:$PATH"