-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc.tmpl
More file actions
177 lines (143 loc) · 3.89 KB
/
dot_zshrc.tmpl
File metadata and controls
177 lines (143 loc) · 3.89 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
{{- if eq .chezmoi.os "linux" }}
if [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
{{- end }}
autoload -Uz compinit
compinit
export EDITOR=nvim
{{- if eq .chezmoi.os "darwin" }}
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH"
{{- end }}
# for Lazygit config to work
export XDG_CONFIG_HOME="$HOME/.config"
export PATH="$HOME/.local/bin:$HOME/.bun/bin:$HOME/.amp/bin:$HOME/.opencode/bin:$PATH"
{{- if eq .chezmoi.os "darwin" }}
export PATH="/Applications/Obsidian.app/Contents/MacOS:$PATH"
{{- else if eq .chezmoi.os "linux" }}
export PATH="/usr/local/bin/obsidian:$PATH"
{{- end }}
alias l="eza --color=always --icons --all --long --time modified --sort modified --no-permissions --octal-permissions --git --smart-group --git-repos"
alias v="nvim"
alias en="cd ~/.config/nvim && nvim"
alias sf="source ~/.zshrc"
alias c="clear"
alias ef="nvim ~/.zshrc"
alias cc="claude"
alias oc="opencode"
alias se="source .venv/bin/activate"
alias cx="codex"
__theme_name_for_mode() {
case "$1" in
light) printf '%s\n' cyberdream-light ;;
*) printf '%s\n' cyberdream ;;
esac
}
__current_theme_mode() {
local state_path="$HOME/.local/state/theme-mode"
local mode
if [[ -f "$state_path" ]]; then
IFS= read -r mode < "$state_path"
case "$mode" in
light|dark)
printf '%s\n' "$mode"
return 0
;;
esac
fi
printf '%s\n' dark
}
__apply_theme_env() {
local mode="$1"
local theme
theme="$(__theme_name_for_mode "$mode")"
export THEME_MODE="$mode"
export BAT_THEME="$theme"
}
theme-dark() {
theme-mode dark >/dev/null || return 1
__apply_theme_env dark
}
theme-light() {
theme-mode light >/dev/null || return 1
__apply_theme_env light
}
ccd() {
cd "$(chezmoi source-path)"
}
{{- if eq .chezmoi.os "linux" }}
{{- if (.chezmoi.kernel.osrelease | lower | contains "microsoft") }}
# Copy file(s) to WSL Desktop
copy-to-desktop() {
if [ "$#" -eq 0 ]; then
echo "Usage: copy-to-desktop <file1> [file2 ...]"
return 1
fi
local target_dir="/mnt/c/Users/frixa/Desktop"
if [ ! -d "$target_dir" ]; then
echo "Error: Desktop directory not found: $target_dir"
return 1
fi
for file in "$@"; do
if [ -e "$file" ]; then
cp "$file" "$target_dir"
echo "Copied: $file -> $target_dir/"
else
echo "Error: File not found: $file"
fi
done
}
{{- end }}
{{- end }}
envsource() {
if [ ! -f "$1" ]; then
echo "Error: File $1 not found"
return 1
fi
while IFS= read -r line || [ -n "$line" ]; do
case "$line" in
\#*|"") continue ;;
esac
key="${line%%=*}"
value="${line#*=}"
value="${value#\"}" ; value="${value%\"}"
value="${value#\'}" ; value="${value%\'}"
export "$key=$value"
done < "$1"
}
function g() {
local original_dir="$(pwd)"
lazygit "$@"
cd "$original_dir"
}
function j() {
local original_dir="$(pwd)"
jjui "$@"
cd "$original_dir"
}
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
IFS= read -r -d '' cwd < "$tmp"
[ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd"
rm -f -- "$tmp"
}
if [[ -f ~/.config/zsh/env.zsh ]]; then
source ~/.config/zsh/env.zsh
fi
__apply_theme_env "$(__current_theme_mode)"
if [[ -o interactive ]]; then
(( $+commands[zoxide] )) && eval "$(zoxide init zsh)"
(( $+commands[starship] )) && eval "$(starship init zsh)"
(( $+commands[fzf] )) && eval "$(fzf --zsh)"
(( $+commands[mise] )) && eval "$(mise activate zsh)"
fi
{{ if and .work (eq .chezmoi.os "darwin") -}}
(( $+commands[rbenv] )) && eval "$(rbenv init - zsh)"
{{- end -}}
{{- if eq .chezmoi.os "darwin" }}
source ~/.orbstack/shell/init.zsh 2>/dev/null || :
{{- end }}