Skip to content

Instantly share code, notes, and snippets.

@SvenZhao
Last active March 6, 2026 07:30
Show Gist options
  • Select an option

  • Save SvenZhao/fc2e492c1a0c4a3fc2a0f4f8427a5cd9 to your computer and use it in GitHub Desktop.

Select an option

Save SvenZhao/fc2e492c1a0c4a3fc2a0f4f8427a5cd9 to your computer and use it in GitHub Desktop.
linux设置
unbind ^b
set -g prefix 'm-`'
#set -g prefix 'c-a'
set -g mouse on
setw -g mode-keys vi
bind '"' split-window -c '#{pane_current_path}'
bind '%' split-window -h -c '#{pane_current_path}'
set-option -g escape-time 50
#brew相关的环境变量
eval $(/opt/homebrew/bin/brew shellenv) #brew.idayer.com
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git" #brew.idayer.com
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git" #brew.idayer.com
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api" #brew.idayer.com
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/bottles" #brew.idayer.com
#brew 安装的软件
eval "$(zoxide init zsh)"
# fnm
FNM_PATH="/Users/sven/Library/Application Support/fnm"
if [ -d "$FNM_PATH" ]; then
export PATH="/Users/sven/Library/Application Support/fnm:$PATH"
eval "`fnm env`"
fi
# bun completions
[ -s "/Users/sven/.bun/_bun" ] && source "/Users/sven/.bun/_bun"
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# 添加 npm 全局前缀到 PATH
export PATH="/Users/sven/.npm_global/bin:$PATH"
# ============================================================
# Zsh 配置 - 极速优化版
# ============================================================
# 去重 PATH
typeset -U PATH
# 仅在非登录 shell 时加载 .zprofile
if [[ ! -o login ]]; then
[[ -f ~/.zprofile ]] && source ~/.zprofile
fi
# ============================================================
# Powerlevel10k Instant Prompt(必须放在最前面)
# ============================================================
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# ============================================================
# Oh-My-Zsh 配置(精简加载)
# ============================================================
export ZSH="/Users/sven/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
# ========== 性能优化 ==========
zstyle ':omz:update' mode disabled
DISABLE_AUTO_UPDATE="true"
DISABLE_MAGIC_FUNCTIONS="true"
DISABLE_AUTO_TITLE="true"
ZSH_DISABLE_COMPFIX="true"
# 禁用 git 插件的脏状态检查(大幅提升 git 仓库中的速度)
DISABLE_UNTRACKED_FILES_DIRTY="true"
GIT_STATUS_SHOW_STASH="false"
GIT_STATUS_SHOW_UNTRACKED="false"
# 最小插件集
plugins=(git)
source $ZSH/oh-my-zsh.sh
# ============================================================
# 延迟加载插件(首次使用时才加载)
# ============================================================
# 延迟加载 autosuggestions(按 Tab 或输入时才激活)
_autosuggestions_lazy_load() {
# 只加载一次
if [[ -z "$_AUTOSUGGESTIONS_LOADED" ]]; then
source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh 2>/dev/null
_AUTOSUGGESTIONS_LOADED=1
# 移除这个钩子
add-zsh-hook -d precmd _autosuggestions_lazy_load
fi
}
autoload -Uz add-zsh-hook
add-zsh-hook precmd _autosuggestions_lazy_load
# zsh-syntax-highlighting(必须最后加载,限制高亮长度优化粘贴)
ZSH_HIGHLIGHT_MAXLENGTH=300
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null
# ============================================================
# 粘贴性能优化
# ============================================================
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2]}
zle -N self-insert url-quote-magic
}
pastefinish() {
zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic
# ============================================================
# 别名设置
# ============================================================
alias n="npm run"
alias rmdir='rm -rf'
alias o2d='o2 p -d'
alias o2p='o2 p -o'
alias vim='nvim'
alias vi='nvim'
alias proxy='export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890'
# ============================================================
# 其他配置
# ============================================================
# p10k 主题配置
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# golang
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
# 鸿蒙
export PATH=~/Library/OpenHarmony/Sdk/20/toolchains:$PATH
export HDC_SERVER_PORT=7035
launchctl setenv HDC_SERVER_PORT $HDC_SERVER_PORT
# 本地环境
[[ -f "$HOME/.local/bin/env" ]] && . "$HOME/.local/bin/env"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment