sync: align home-manager zsh.nix with actual .zshrc

- Add envExtra: PATH, XDG_CONFIG_HOME, POWERLEVEL9K_INSTANT_PROMPT, .hermes/node/bin
- Add shell options: correct, interactive_comments
- Add initExtra: p10k instant prompt, y() function, proxy-on/off aliases
- Add missing aliases: cd -# (1-9), _ (sudo), rd, grep variants, afind, globurl
- Add missing OMZ plugins: command-not-found, colored-man-pages, kubectl
This commit is contained in:
luochen570
2026-05-26 12:45:07 +08:00
parent e6f99590c5
commit 4349da57ea

View File

@@ -1,61 +1,118 @@
{ config, pkgs, inputs, system, ... }: { config, pkgs, inputs, system, ... }:
{ programs.zsh = { {
enable = true; programs.zsh = {
enableCompletion = true; enable = true;
autosuggestion.enable = true; enableCompletion = true;
syntaxHighlighting.enable = true; autosuggestion.enable = true;
# initContent = "source ~/.p10k.zsh"; syntaxHighlighting.enable = true;
plugins = [
{ # 环境变量 - 对应 .zshrc 开头的环境设置
name = "powerlevel10k"; envExtra = ''
src = pkgs.zsh-powerlevel10k; path=(~/.local/bin $path)
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; export XDG_CONFIG_HOME="''${XDG_CONFIG_HOME:-$HOME/.config}"
} export POWERLEVEL9K_INSTANT_PROMPT=quiet
{ export PATH="$HOME/.hermes/node/bin:$PATH"
name = "fzf-tab"; '';
src = "${pkgs.zsh-fzf-tab}/share/fzf-tab";
} # Shell 选项 - 对应 .zshrc 的 setopt
# { options = [ "correct" "interactive_comments" ];
# name = "powerlevel10k-config";
# src = "/home/luochen570/nixos-config/modules/home/p10k/"; # 初始化 - 对应 .zshrc 中的 Powerlevel10k instant prompt 和函数定义
# file = "p10k.zsh"; initExtra = ''
# } # Powerlevel10k instant prompt
]; if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
# 设置alias source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
shellAliases = { fi
# Git相关
gc1 = "git clone --recursive --depth=1"; # Powerlevel10k config
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# 目录操作
md = "mkdir -p"; # yazi: open and jump to last cwd
"..." = "../.."; function y() {
"...." = "../../.."; local tmp cwd
"....." = "../../../.."; tmp="$(mktemp -t yazi-cwd.XXXXXX)"
"......" = "../../../../.."; yazi "$@" --cwd-file="$tmp"
cwd="$(cat -- "$tmp")"
# eza/ls替代 if [[ -n "$cwd" && "$cwd" != "$PWD" ]]; then
ls = "eza --color=auto"; builtin cd -- "$cwd"
l = "eza -lbah --icons=auto"; fi
la = "eza -labgh --icons=auto"; rm -f -- "$tmp"
ll = "eza -lbg --icons=auto"; }
lt = "eza -lTbg --icons=auto";
lsa = "eza -lbagR --icons=auto"; #
lst = "eza -lTabgh --icons=auto"; alias proxy-on='export http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890'
alias proxy-off='unset http_proxy https_proxy'
# bat/cat替代 '';
cat = "bat -pp";
ccat = "cat"; plugins = [
}; {
name = "powerlevel10k";
oh-my-zsh = { src = pkgs.zsh-powerlevel10k;
enable = true; file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
plugins = [ }
"sudo" {
"z" name = "fzf-tab";
"extract" src = "${pkgs.zsh-fzf-tab}/share/fzf-tab";
"git" }
# "fzf-tab" ];
];
}; # 设置 alias - 对应 .zshrc 中的 aliases 部分
}; shellAliases = {
} # 目录导航
"..." = "../..";
"...." = "../../..";
"....." = "../../../..";
"......" = "../../../../..";
"1" = "cd -";
"2" = "cd -2";
"3" = "cd -3";
"4" = "cd -4";
"5" = "cd -5";
"6" = "cd -6";
"7" = "cd -7";
"8" = "cd -8";
"9" = "cd -9";
# 快捷操作
"_" = "sudo ";
gc1 = "git clone --recursive --depth=1";
# 目录操作
md = "mkdir -p";
rd = "rmdir";
# grep
grep = "grep --color=auto";
egrep = "egrep --color=auto";
fgrep = "fgrep --color=auto";
afind = "ack -il";
globurl = "noglob urlglobber ";
# eza/ls 替代
ls = "eza --color=auto";
l = "eza -lbah --icons=auto";
la = "eza -labgh --icons=auto";
ll = "eza -lbg --icons=auto";
lt = "eza -lTbg --icons=auto";
lsa = "eza -lbagR --icons=auto";
lst = "eza -lTabgh --icons=auto";
# bat/cat 替代
cat = "bat -pp";
ccat = "cat";
};
oh-my-zsh = {
enable = true;
plugins = [
"sudo"
"z"
"extract"
"git"
"command-not-found"
"colored-man-pages"
"kubectl"
];
};
};
}