-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
206 lines (169 loc) · 4.89 KB
/
dot_zshrc.tmpl
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
unsetopt beep
# History
export HISTFILE="${STATE_DIR}/zsh/history"
HISTSIZE=2000
SAVEHIST=1000
# Prompt
PROMPT='%n@%m:%1~ %% '
if [ ! -z "$SSH_CLIENT" ]; then
PROMPT='%F{green}%n@%m%f:%1~ %% '
fi
# Key bindings
bindkey -e
# Default programs
if command -v vim 1>/dev/null 2>&1; then
export EDITOR="vim"
export VISUAL="vim"
fi
if command -v delta 1>/dev/null 2>&1; then
export GIT_PAGER="delta"
fi
# Disable builtin commands
disable -r time
# Aliases
alias ll='ls -alv'
alias la='ls -A'
alias l='ls -CF'
{{- if eq .chezmoi.os "darwin" }}
alias typora="open -a typora"
{{- end }}
if command -v gojq 1>/dev/null 2>&1; then
alias jq=gojq
fi
if command -v gojq 1>/dev/null 2>&1; then
alias http=xh
fi
if command -v wget2 1>/dev/null 2>&1; then
alias wget=wget2
fi
if command -v mitmproxy 1>/dev/null 2>&1; then
alias mitmproxy="mitmproxy --set confdir=${STATE_DIR}/mitmproxy"
fi
# FPATH
FUNC_DIRS=(
"/nix/var/nix/profiles/default/share/zsh/site-functions"
"${NIX_PROFILE_DIR}/share/zsh/site-functions"
/usr/share/zsh/site-functions
/opt/homebrew/share/zsh/site-functions
)
for FUNC_DIR in ${FUNC_DIRS[@]}; do
FPATH="${FUNC_DIR}:${FPATH}"
done
# Completions
autoload -Uz compinit && compinit -d "${CACHE_DIR}/zsh/zcompdump-${ZSH_VERSION}"
zstyle ':completion:*' cache-path "${CACHE_DIR}/zsh/zcompcache"
# Kafka
if command -v kafka 1>/dev/null 2>&1; then
source <(kafka completion zsh) && compdef _kafka kafka
fi
# Extensions
# Zoxide
if command -v zoxide 1>/dev/null 2>&1; then
eval "$(zoxide init zsh)"
fi
# Atuin
if command -v atuin 1>/dev/null 2>&1; then
eval "$(atuin init zsh)"
fi
# zsh-autosuggestions
if [ -f "${NIX_PROFILE_DIR}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" ]; then
source "${NIX_PROFILE_DIR}/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
fi
# zsh-syntax-highlighting
if [ -f "${NIX_PROFILE_DIR}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then
source "${NIX_PROFILE_DIR}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
fi
# Functions
function proxy_on() {
export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export ALL_PROXY=socks5://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890
}
function proxy_off() {
unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy
}
function ipython() {
nix-shell -p python3Packages.ipython --command "ipython $@"
}
function config-git-user() {
git config --local user.name "Aaron Jheng"
git config --local user.email "[email protected]"
git config --local user.signingkey F6A547A869D050A3
}
{{ if eq .chezmoi.os "darwin" -}}
function system_proxy_on() {
networksetup -setsecurewebproxystate 'Wi-Fi' on
networksetup -setwebproxystate 'Wi-Fi' on
networksetup -setsocksfirewallproxystate 'Wi-Fi' on
}
function system_proxy_off() {
networksetup -setsecurewebproxystate 'Wi-Fi' off
networksetup -setwebproxystate 'Wi-Fi' off
networksetup -setsocksfirewallproxystate 'Wi-Fi' off
}
function system_proxy_setup() {
host="127.0.0.1"
port="7890"
if [[ -n "$1" ]]; then
host=$1
fi
if [[ -n "$2" ]]; then
port=$2
fi
networksetup -setsecurewebproxy 'Wi-Fi' "${host}" "${port}"
networksetup -setwebproxy 'Wi-Fi' "${host}" "${port}"
networksetup -setsocksfirewallproxy 'Wi-Fi' "${host}" "${port}"
networksetup -setproxybypassdomains 'Wi-Fi' '*.local' '10.*' '127.0.0.*' '192.168.*' 'example.dev' '*.example.dev'
}
function mitmproxy_setup() {
host="aarons-nuc.local"
port="9118"
if [[ -n "$1" ]]; then
host=$1
fi
if [[ -n "$2" ]]; then
port=$2
fi
networksetup -setsecurewebproxy 'Wi-Fi' "${host}" "${port}"
networksetup -setwebproxy 'Wi-Fi' "${host}" "${port}"
networksetup -setsocksfirewallproxy 'Wi-Fi' "${host}" "${port}"
networksetup -setproxybypassdomains 'Wi-Fi' '*.local' '10.*' '127.0.0.*' '192.168.*' 'example.dev' '*.example.dev'
}
function system_proxy_show() {
echo "HTTPS Proxy"
networksetup -getsecurewebproxy 'Wi-Fi'
echo ""
echo "HTTP Proxy"
networksetup -getwebproxy 'Wi-Fi'
echo ""
echo "SOCKS Proxy"
networksetup -getsocksfirewallproxy 'Wi-Fi'
echo ""
echo "Proxy Bypass Domains"
networksetup -getproxybypassdomains 'Wi-Fi'
}
function gonuc() {
local serial=`system_profiler SPHardwareDataType | grep "Serial Number (system)" | cut -d ":" -f 2 | xargs`
ssh -t aarons-nuc.local "tmux -CC new -A -s workspace-${serial}"
}
function govm() {
local serial=`system_profiler SPHardwareDataType | grep "Serial Number (system)" | cut -d ":" -f 2 | xargs`
ssh -t aarons-work-vm.local "tmux -CC new -A -s workspace-${serial}"
}
function launchctl() {
case "$1" in
"reload")
command launchctl unload "$2" && command launchctl load "$2"
;;
"restart")
command launchctl stop "$2" && command launchctl start "$2"
;;
*)
command launchctl "$@"
;;
esac
}
{{ end -}}