refactor(zsh): 移除 zsh 模块与配置

This commit is contained in:
2026-04-09 15:50:34 +08:00
parent 193cbdb11b
commit 33f4beb72a
4 changed files with 18 additions and 168 deletions
-102
View File
@@ -1,102 +0,0 @@
# ── PATH ──
export PATH="$HOME/go/bin:$HOME/.bun/bin:$PATH"
# ── 默认编辑器与分页器 ──
export EDITOR=nvim
export VISUAL=nvim
export PAGER=less
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
# ── Shell 选项 ──
setopt AUTO_CD # 输目录名直接 cd
setopt INTERACTIVE_COMMENTS # 允许交互式 # 注释
setopt NO_BEEP # 关蜂鸣
# ── 补全系统(必须在 fzf-tab 之前)──
# 每天重建一次 zcompdump,其余启动直接复用,节省启动时间
autoload -Uz compinit
if [[ -n ~/.zcompdump(#qN.mh+24) ]]; then
compinit
else
compinit -C
fi
# 保留大小写敏感优先,找不到时再回退到大小写不敏感补全
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
# ── 外部插件 ──
source /usr/share/zsh/plugins/fzf-tab-git/fzf-tab.plugin.zsh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # 必须最后
# ── 双击 ESC 自动加 sudo ──
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
zle end-of-line
}
zle -N sudo-command-line
bindkey '\e\e' sudo-command-line
# ── Ctrl+Space 接受自动建议 ──
bindkey '^ ' autosuggest-accept
# ── FZF 默认行为(fd 联动 + 现代 UI)──
export FZF_DEFAULT_OPTS='--height=50% --layout=reverse --border --preview-window=right:60%'
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git'
# ── 工具初始化(顺序重要)──
eval "$(starship init zsh)"
eval "$(zoxide init --cmd cd zsh)" # cd 直接被 zoxide 接管,cdi 自动可用
eval "$(mise activate zsh)"
eval "$(direnv hook zsh)"
eval "$(fzf --zsh)" # Ctrl+T 搜文件, Alt+C 搜目录
eval "$(atuin init zsh)" # 必须在 fzf 之后,接管 Ctrl+R
# ── 别名 ──
# 导航
alias ..="cd .."
alias ...="cd ../.."
# 文件列表(公共参数提取,DRY
_EZA_BASE=(--icons --group-directories-first --git)
alias ls="eza ${_EZA_BASE}"
alias l="eza -la ${_EZA_BASE}"
alias ll="eza -l ${_EZA_BASE}"
alias la="eza -lA ${_EZA_BASE}"
alias lt="eza --tree --level=2 ${_EZA_BASE}"
# 工具
alias cat="bat --paging=never"
alias rm="gomi"
alias lg="lazygit"
alias vi="nvim"
alias x="ouch decompress" # 万能解压(zip/tar/gz/bz2/xz/zst/7z/rar
# ── yazi wrapper:退出时自动 cd 到最后目录 ──
function yy() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [[ -n "$cwd" && "$cwd" != "$PWD" ]]; then
builtin cd -- "$cwd"
fi
command rm -f -- "$tmp"
}
# ── WSL 集成 ──
if [[ -n "$WSL_DISTRO_NAME" ]]; then
# 剪贴板互通
alias pbcopy="clip.exe"
alias pbpaste="powershell.exe -noprofile -c Get-Clipboard"
# Windows Terminal: 新标签/窗格继承当前目录(OSC 9;9 序列)
keep_current_path() {
printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"
}
precmd_functions+=(keep_current_path)
fi
# ── Local ──
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local