-
Notifications
You must be signed in to change notification settings - Fork 25
/
.zshrc.local
121 lines (101 loc) · 3.8 KB
/
.zshrc.local
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
# Local configurations -*- mode: sh -*-
# Theme
if (( $+commands[starship] )) && [ -z "$INSIDE_EMACS" ]; then
# Load starship theme (requires nerd fonts)
eval "$(starship init zsh)"
else
# Load the pure theme, with zsh-async library that's bundled with it.
zinit ice depth"1" pick"async.zsh" src"pure.zsh"
zinit light sindresorhus/pure
fi
# Plugins
# zinit wait lucid for \
# OMZP::python \
# OMZP::golang \
# OMZP::ruby \
# OMZP::rbenv \
# OMZP::rails \
# OMZP::rust
# zinit as"completion" wait lucid for \
# OMZP::docker/_docker \
# OMZP::rust/_rustc
# Show system information
# (( $+commands[neofetch] )) && neofetch
# iTerm2 shell integration
# if test -e "${HOME}/.iterm2_shell_integration.zsh"; then
# source "${HOME}/.iterm2_shell_integration.zsh"
# fi
# For Emacs vterm
if [ -n "$INSIDE_EMACS" ]; then
DISABLE_AUTO_TITLE="true"
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#525252'
# VTerm
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
vterm_printf() {
if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ]); then
# Tell tmux to pass the escape sequences through
printf "\ePtmux;\e\e]%s\007\e\\" "$1"
elif [ "${TERM%%-*}" = "screen" ]; then
# GNU screen (screen, screen-256color, screen-256color-bce)
printf "\eP\e]%s\007\e\\" "$1"
else
printf "\e]%s\e\\" "$1"
fi
}
alias clear='vterm_printf "51;Evterm-clear-scrollback";tput clear'
fi
fi
# Env
# export EDITOR=vim
# PROXY=http://127.0.0.1:7897
# setproxy
# Aliases
[[ $OSTYPE == darwin* ]] && alias flush_dns='sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder'
# Homebrew
if [[ $OSTYPE == darwin* ]]; then
# For Apple Silicon CPU
[[ $CPUTYPE == arm* ]] && eval "$(/opt/homebrew/bin/brew shellenv)"
function set_homebrew_env()
{
# https://mirrors.ustc.edu.cn/
# https://mirrors.tnua.tsinghua.edu.cn/
# https://mirrors.bfsu.edu.cn/
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_PIP_INDEX_URL="https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
}
function set_homebrew_mirror() {
set_homebrew_env
brew tap --custom-remote --force-auto-update homebrew/command-not-found https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-command-not-found.git
brew update
}
function unset_homebrew_env {
unset HOMEBREW_API_DOMAIN
unset HOMEBREW_BREW_GIT_REMOTE
unset HOMEBREW_CORE_GIT_REMOTE
unset HOMEBREW_BOTTLE_DOMAIN
unset HOMEBREW_PIP_INDEX_URL
}
function reset_homebrew_mirror() {
unset_homebrew_env
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew
BREW_TAPS="$(BREW_TAPS="$(brew tap 2>/dev/null)"; echo -n "${BREW_TAPS//$'\n'/:}")"
for tap in core cask command-not-found; do
if [[ ":${BREW_TAPS}:" == *":homebrew/${tap}:"* ]]; then
brew tap --custom-remote "homebrew/${tap}" "https://github.com/Homebrew/homebrew-${tap}"
fi
done
brew update
}
# Use mirror env by default
set_homebrew_env
fi
# Golang
# Go Proxy
export GOPROXY=https://proxy.golang.com.cn,direct
# export GOPROXY=https://goproxy.cn,direct
# export GOPROXY=https://goproxy.io,direct
# Go Private
# export GOPRIVATE=