-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc
More file actions
203 lines (160 loc) · 4.9 KB
/
dot_zshrc
File metadata and controls
203 lines (160 loc) · 4.9 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
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
export ZSH="$HOME/.oh-my-zsh"
fpath+=("$(brew --prefix)/share/zsh/site-functions")
autoload -U promptinit; promptinit
prompt pure
plugins=(
git
brew
node
pnpm
colored-man-pages
colorize
kubectl
tmux
zsh-autosuggestions
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
# Alias
alias ll='ls -al'
alias la='ls -a'
alias vim='nvim'
alias vi='nvim'
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -f $HOMEBREW_PREFIX/etc/profile.d/autojump.sh ] && . $HOMEBREW_PREFIX/etc/profile.d/autojump.sh
# Go proxy
export GOPROXY=https://goproxy.cn
# fzf
eval "$(fzf --zsh)"
# kitty ssh fix
[[ "$TERM" == "xterm-kitty" ]] && alias ssh="TERM=xterm-256color ssh"
# Kubectl
source <(kubectl completion zsh)
# Android
## Java
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
# Rust
export PATH=$PATH:$HOME/.cargo/bin
# Ruby
export PATH="$HOME/.rbenv/bin:$PATH"
# FZF
export FZF_DEFAULT_OPTS=" \
--color=bg+:#363a4f,bg:#24273a,spinner:#f4dbd6,hl:#ed8796 \
--color=fg:#cad3f5,header:#ed8796,info:#c6a0f6,pointer:#f4dbd6 \
--color=marker:#b7bdf8,fg+:#cad3f5,prompt:#c6a0f6,hl+:#ed8796 \
--color=selected-bg:#494d64 \
--multi"
# Proxy helpers (HTTP/HTTPS + ALL/SOCKS)
# Default proxy addresses; change if you use different host/port.
PROXY_HTTP_URL="http://127.0.0.1:7897"
PROXY_SOCKS_URL="socks5://127.0.0.1:7897"
# Enable proxy (exports both lowercase and uppercase variants and a basic no_proxy)
proxy_on() {
export http_proxy="$PROXY_HTTP_URL"
export https_proxy="$PROXY_HTTP_URL"
export all_proxy="$PROXY_SOCKS_URL"
# Uppercase variants for programs that look for them
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$https_proxy"
export ALL_PROXY="$all_proxy"
# Common local addresses to bypass the proxy
export no_proxy="localhost,127.0.0.1,::1"
echo "Proxy enabled: $http_proxy (HTTP/HTTPS), $all_proxy (ALL)"
}
# Disable proxy
proxy_off() {
unset http_proxy https_proxy all_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY no_proxy
echo "Proxy disabled"
}
# Print proxy status
proxy_status() {
printf "http_proxy=%s\nhttps_proxy=%s\nall_proxy=%s\n" "${http_proxy:-<unset>}" "${https_proxy:-<unset>}" "${all_proxy:-<unset>}"
}
# Toggle proxy (on if currently off, off if currently on)
proxy_toggle() {
if [ -n "${http_proxy-}" ]; then
proxy_off
else
proxy_on
fi
}
# Proxyman proxy (enable Proxyman at 127.0.0.1:9090)
proxyman_on() {
export http_proxy="http://127.0.0.1:9090"
export https_proxy="http://127.0.0.1:9090"
# Uppercase variants for programs that look for them
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$https_proxy"
# Basic no_proxy
export no_proxy="localhost,127.0.0.1,::1"
echo "Proxyman proxy enabled: $http_proxy (HTTP/HTTPS)"
}
# Convenience aliases
alias proxyman-enable='proxyman_on'
alias proxy-enable='proxy_on'
alias proxy-disable='proxy_off'
alias proxy-toggle='proxy_toggle'
# Auto-enable proxy on shell startup
# Ways to enable by default:
# 1) set environment variable PROXY_AUTO=1 (e.g. export PROXY_AUTO=1 in your environment)
# 2) create a file $HOME/.proxy_on
# 3) set PROXY_AUTO_HOSTS to a space-separated list of hostnames and if current hostname
# is in that list the proxy will be enabled automatically.
# To avoid printing the enable message, set PROXY_AUTO_QUIET=1.
PROXY_AUTO=${PROXY_AUTO:-0}
PROXY_AUTO_HOSTS=${PROXY_AUTO_HOSTS:-}
PROXY_AUTO_QUIET=${PROXY_AUTO_QUIET:-0}
_should_auto_enable_proxy() {
# 1) env flag
if [ "$PROXY_AUTO" = "1" ]; then
return 0
fi
# 2) presence of toggle file
if [ -f "$HOME/.proxy_on" ]; then
return 0
fi
# 3) hostname match
if [ -n "$PROXY_AUTO_HOSTS" ]; then
# Surround with spaces to avoid partial matches
if [[ " $PROXY_AUTO_HOSTS " == *" $(hostname) "* ]]; then
return 0
fi
fi
return 1
}
if _should_auto_enable_proxy; then
if [ "$PROXY_AUTO_QUIET" = "1" ]; then
proxy_on >/dev/null 2>&1
else
proxy_on
fi
fi
# asdf
export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"
# zsh vi
bindkey -v
# The following lines have been added by Docker Desktop to enable Docker CLI completions.
fpath=(/Users/shiwei/.docker/completions $fpath)
autoload -Uz compinit
compinit
# End of Docker CLI completions
# go bin
. ${ASDF_DATA_DIR:-$HOME/.asdf}/plugins/golang/set-env.zsh
. "$HOME/.local/bin/env"
# bun completions
[ -s "/Users/shiwei/.bun/_bun" ] && source "/Users/shiwei/.bun/_bun"
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# 自动启用代理
export PROXY_AUTO=1
export PROXY_AUTO_QUIET=1
# Added by Antigravity
export PATH="/Users/shiwei/.antigravity/antigravity/bin:$PATH"
# OpenClaw Completion
source <(openclaw completion --shell zsh)