diff --git a/home/.zshrc b/home/.zshrc index a0fc992..9a5611a 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -1,13 +1,25 @@ # ── 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 之前)── -autoload -Uz compinit && compinit +# 每天重建一次 zcompdump,其余启动直接复用,节省启动时间 +autoload -Uz compinit +if [[ -n ~/.zcompdump(#qN.mh+24) ]]; then + compinit +else + compinit -C +fi # ── 外部插件 ── source /usr/share/zsh/plugins/fzf-tab-git/fzf-tab.plugin.zsh @@ -23,9 +35,18 @@ sudo-command-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 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 搜目录 @@ -33,16 +54,15 @@ eval "$(atuin init zsh)" # 必须在 fzf 之后,接管 Ctrl+R # ── 别名 ── # 导航 -alias cd="z" -alias cdi="zi" alias ..="cd .." alias ...="cd ../.." -# 文件列表 -alias ls="eza --icons --group-directories-first" -alias ll="eza -la --icons --git --group-directories-first" -alias la="eza -a --icons --group-directories-first" -alias lt="eza --tree --level=2 --icons" +# 文件列表(公共参数提取,DRY) +_EZA_BASE=(--icons --group-directories-first --git) +alias ls="eza ${_EZA_BASE}" +alias ll="eza -la ${_EZA_BASE}" +alias la="eza -a ${_EZA_BASE}" +alias lt="eza --tree --level=2 ${_EZA_BASE}" # 工具 alias cat="bat --paging=never" @@ -54,6 +74,16 @@ alias x="ouch decompress" # 万能解压(zip/tar/gz/bz2/xz/zst/7z/rar) # 网络 alias http="xh" +# ── 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" diff --git a/modules/base.py b/modules/base.py index 88e00be..d48e66e 100644 --- a/modules/base.py +++ b/modules/base.py @@ -57,7 +57,6 @@ class BaseModule(Module): "starship", "sudo", "tealdeer", - "vim", "wget", "xh", "yazi",