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,10 +1,49 @@
{ config, pkgs, inputs, system, ... }:
{ programs.zsh = {
{
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
# initContent = "source ~/.p10k.zsh";
# 环境变量 - 对应 .zshrc 开头的环境设置
envExtra = ''
path=(~/.local/bin $path)
export XDG_CONFIG_HOME="''${XDG_CONFIG_HOME:-$HOME/.config}"
export POWERLEVEL9K_INSTANT_PROMPT=quiet
export PATH="$HOME/.hermes/node/bin:$PATH"
'';
# Shell 选项 - 对应 .zshrc 的 setopt
options = [ "correct" "interactive_comments" ];
# 初始化 - 对应 .zshrc 中的 Powerlevel10k instant prompt 和函数定义
initExtra = ''
# 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
# Powerlevel10k config
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# 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")"
if [[ -n "$cwd" && "$cwd" != "$PWD" ]]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
#
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'
'';
plugins = [
{
name = "powerlevel10k";
@@ -15,25 +54,41 @@
name = "fzf-tab";
src = "${pkgs.zsh-fzf-tab}/share/fzf-tab";
}
# {
# name = "powerlevel10k-config";
# src = "/home/luochen570/nixos-config/modules/home/p10k/";
# file = "p10k.zsh";
# }
];
# 设置alias
shellAliases = {
# Git相关
gc1 = "git clone --recursive --depth=1";
# 目录操作
md = "mkdir -p";
# 设置 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";
# eza/ls替代
# 快捷操作
"_" = "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";
@@ -42,7 +97,7 @@
lsa = "eza -lbagR --icons=auto";
lst = "eza -lTabgh --icons=auto";
# bat/cat替代
# bat/cat 替代
cat = "bat -pp";
ccat = "cat";
};
@@ -54,8 +109,10 @@
"z"
"extract"
"git"
# "fzf-tab"
"command-not-found"
"colored-man-pages"
"kubectl"
];
};
};
}
}