- 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
119 lines
3.0 KiB
Nix
119 lines
3.0 KiB
Nix
{ config, pkgs, inputs, system, ... }:
|
|
{
|
|
programs.zsh = {
|
|
enable = true;
|
|
enableCompletion = true;
|
|
autosuggestion.enable = true;
|
|
syntaxHighlighting.enable = true;
|
|
|
|
# 环境变量 - 对应 .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";
|
|
src = pkgs.zsh-powerlevel10k;
|
|
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
|
|
}
|
|
{
|
|
name = "fzf-tab";
|
|
src = "${pkgs.zsh-fzf-tab}/share/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"
|
|
];
|
|
};
|
|
};
|
|
}
|