Files
nix-config/home/shell.nix
T
imbytecat d58c650d59 feat: NixOS 声明式配置(从 Arch + decman 迁移)
- flake.nix: NixOS + home-manager + nixos-wsl 三输入
- hosts/wsl + hosts/bare: WSL 与裸机共享模块,分主机配置
- modules/: base(CLI 工具) + dev(工具链+LSP) + docker + locale + shell
- home/: zsh(oh-my-zsh+插件+别名) + git(delta) + starship + 工具集成
- scripts/install.sh: 一键安装脚本(WSL/裸机通用)
- 原 bun/go 全局包 hack 改为 nixpkgs 声明式管理
2026-04-03 19:05:06 +08:00

138 lines
4.0 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{ config, pkgs, ... }:
{
# ── Zsh ──────────────────────────────────────────────
programs.zsh = {
enable = true;
autocd = true; # setopt AUTO_CD
oh-my-zsh = {
enable = true;
plugins = [
"git" # git 别名 (gst, gco, gp...)
"sudo" # 双击 ESC 自动加 sudo
"extract" # x file.tar.gz 一键解压
"direnv" # direnv hook
];
};
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
# 导航
cd = "z";
cdi = "zi";
".." = "cd ..";
"..." = "cd ../..";
# 文件列表
ls = "eza --icons --group-directories-first";
ll = "eza -la --icons --git --group-directories-first";
la = "eza -a --icons --group-directories-first";
lt = "eza --tree --level=2 --icons";
# 工具
cat = "bat --paging=never";
rm = "trash-put";
lg = "lazygit";
vi = "nvim";
# 网络
http = "xh";
};
initExtra = ''
# Shell
setopt INTERACTIVE_COMMENTS
setopt NO_BEEP
# PATH go/bun
export PATH="$HOME/go/bin:$HOME/.bun/bin:$PATH"
# fzf-tab
# : ls $(nix eval --raw nixpkgs#zsh-fzf-tab)/share/
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
# mise
eval "$(mise activate zsh)"
# WSL
if [[ -n "$WSL_DISTRO_NAME" ]]; then
alias pbcopy="clip.exe"
alias pbpaste="powershell.exe -noprofile -c Get-Clipboard"
fi
#
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
'';
};
# ── Starship 提示符 ──────────────────────────────────
programs.starship = {
enable = true;
enableZshIntegration = true;
settings = {
format = "$username$hostname$directory$git_branch$git_status$nodejs$python$go$rust$cmd_duration$line_break$character";
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
directory = {
truncation_length = 3;
truncation_symbol = "/";
};
git_branch.symbol = " ";
git_status.format = "([\\[$all_status$ahead_behind\\]]($style) )";
cmd_duration = {
min_time = 2000;
format = "[$duration]($style) ";
};
nodejs = {
format = "[$symbol($version)]($style) ";
detect_extensions = [ ];
};
python.format = "[$symbol($version)]($style) ";
go.format = "[$symbol($version)]($style) ";
};
};
# ── FZF ──────────────────────────────────────────────
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
# ── Atuin(历史搜索,接管 Ctrl+R)──────────────────
programs.atuin = {
enable = true;
enableZshIntegration = true;
};
# ── Zoxide(智能 cd)─────────────────────────────────
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
# ── Direnv ───────────────────────────────────────────
programs.direnv = {
enable = true;
enableZshIntegration = true;
nix-direnv.enable = true; # 更好的 Nix devShell 集成
};
# ── Bat ──────────────────────────────────────────────
programs.bat.enable = true;
# ── Yazi ─────────────────────────────────────────────
programs.yazi.enable = true;
}