ca971/dotfiles

GitHub: ca971/dotfiles

这是一个基于 SSOT 架构的企业级 dotfiles 框架,通过 TOML 配置为多种 Shell 和平台生成统一且安全加固的开发环境。

Stars: 0 | Forks: 0

# 🔧 Dotfiles **跨平台 · 跨 Shell · SSOT 架构 · 安全加固 · 面向高级用户** 一个精心设计、生产就绪的 dotfiles 框架,基于单一事实来源 (Single Source of Truth) 原则构建,旨在在所有平台和 Shell 上实现最大的一致性、安全性和可维护性。
[![Shell](https://img.shields.io/badge/Shell-ZSH%20·%20Bash%20·%20Fish%20·%20Nushell-green?style=for-the-badge&logo=gnubash&logoColor=white)](#-cross-shell-support) [![Platform](https://img.shields.io/badge/Platform-macOS%20·%20Linux%20·%20WSL-E95420?style=for-the-badge&logo=linux&logoColor=white)](#-cross-platform-support) [![License](https://img.shields.io/badge/License-MIT-F7DF1E?style=for-the-badge)](./LICENSE) [![Tools](https://img.shields.io/badge/Tools-60%2B-blue?style=for-the-badge&logo=hackthebox&logoColor=white)](#-integrated-tools) [![Terminals](https://img.shields.io/badge/Terminals-5-purple?style=for-the-badge&logo=windowsterminal&logoColor=white)](#-terminal--editor-management) [![Startup](https://img.shields.io/badge/Startup-%3C%20500ms-ff6b6b?style=flat-square&logo=speedtest&logoColor=white)](#-performance) [![Themes](https://img.shields.io/badge/Starship-3%20Themes-purple?style=flat-square&logo=starship&logoColor=white)](#-starship-themes) [![Security](https://img.shields.io/badge/Security-Hardened-success?style=flat-square&logo=letsencrypt&logoColor=white)](#-security) [![SSOT](https://img.shields.io/badge/SSOT-TOML%20→%204%20Shells-orange?style=flat-square&logo=toml&logoColor=white)](#-ssot-architecture) [![Maintained](https://img.shields.io/badge/Status-Active-success?style=flat-square)](https://github.com/ca971/dotfiles)
[功能特性](#-key-features) • [安装](#-installation) • [架构](#-architecture) • [CLI](#-dot-cli) • [工具](#-integrated-tools) • [安全](#-security) • [Wiki](https://github.com/ca971/dotfiles/wiki)
## 📑 目录
点击展开 - [💎 企业级优势](#-the-enterprise-edge) - [✨ 核心理念](#-core-philosophy) - [🚀 主要特性](#-key-features) - [🌍 跨平台支持](#-cross-platform-support) - [🐚 跨 Shell 支持](#-cross-shell-support) - [📦 环境需求](#-requirements) - [🔧 安装](#-installation) - [📐 架构](#-architecture) - [🎯 SSOT 架构](#-ssot-architecture) - [🔧 dot CLI](#-dot-cli) - [🎨 Starship 主题](#-starship-themes) - [🛠️ 集成工具](#-integrated-tools) - [🔐 安全性](#-security) - [🔑 SSH 管理](#-ssh-management) - [📝 Git 集成](#-git-integration) - [⚡ 性能](#-performance) - [🧪 测试](#-testing) - [📄 许可证](#-license)
## 💎 企业级优势 无论您是独立开发者、负责基础设施的 DevOps 工程师,还是常驻终端的高级用户 — **Dotfiles Enterprise 都能随您的需求扩展**。 ``` ┌──────────────────────────────────────────────────────────────────┐ │ Dotfiles Enterprise Stack │ ├──────────────────────────────────────────────────────────────────┤ │ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌─────────────────┐ │ │ │ Shells │ │ Tools │ │ Config │ │ Security │ │ │ │ ZSH·Bash │ │ 60+ │ │ SSOT │ │ SSH·GPG·Keys │ │ │ │Fish·Nu │ │ per-file │ │ TOML │ │ Signing·Audit │ │ │ └────┬─────┘ └────┬─────┘ └────┬─────┘ └──────┬──────────┘ │ │ │ │ │ │ │ │ ┌────▼──────────────▼─────────────▼───────────────▼──────────┐ │ │ │ shared/ — POSIX env · PATH · tools-init │ │ │ └────────────────────────────┬───────────────────────────────┘ │ │ │ │ │ ┌────────────────────────────▼───────────────────────────────┐ │ │ │ SSOT Layer (aliases.toml · colors · icons) │ │ │ │ generators → .zsh · .bash · .fish · .nu │ │ │ └────────────────────────────┬───────────────────────────────┘ │ │ │ │ │ ┌────────────────────────────▼───────────────────────────────┐ │ │ │ Platform Layer (macOS · Linux · WSL · Arch · Deb) │ │ │ └────────────────────────────┬───────────────────────────────┘ │ │ │ │ │ ┌────────────────────────────▼───────────────────────────────┐ │ │ │ Terminal Layer (Ghostty · WezTerm · Kitty · Alacritty) │ │ │ └────────────────────────────────────────────────────────────┘ │ └──────────────────────────────────────────────────────────────────┘ ``` ## ✨ 核心理念 | 原则 | 描述 | | :----------------- | :------------------------------------------------------------------- | | 🎯 **SSOT** | 在 TOML 中定义一次,为所有 Shell 生成 — 零重复 | | 🔒 **安全** | SSH 加固、GPG 集成、密钥管理、密钥轮换 | | 🌍 **跨平台** | macOS、Linux、WSL — 自动检测、自动配置 | | 🐚 **跨 Shell** | ZSH、Bash、Fish、Nushell — 共享配置、原生语法 | | ⚡ **极速** | 延迟加载、Turbo 模式、后台编译 — < 500ms | | 🧩 **模块化** | 一个工具 = 一个文件。配置与代码分离 | | 🔧 **零手动配置** | 一切在首次启动时自动配置。无需 `mkdir` | | 📋 **文档齐全** | JSDoc 风格注释、完整的 README、每个命令的帮助文档 | ## 🚀 主要特性
### 🎯 SSOT 架构 - **TOML → 4 个 Shell**:别名、颜色、图标、高亮 - 生成器将 TOML 转换为 ZSH、Bash、Fish、Nushell - 修改一次 → 重新生成 → 所有 Shell 更新 - `config/tools.d/` 用于特定工具定制 - `ssot/aliases.toml` 用于通用 Shell 别名 ### 🐚 多 Shell 支持 - **ZSH** — 功能齐全,含 Zinit 插件和补全 - **Bash** — 轻量级,加载共享环境变量 + SSOT 别名 - **Fish** — 原生缩写、FZF 集成 - **Nushell** — 结构化数据、自定义命令 - 通过 `shells/shared/env.sh` 共享环境变量
### 🔐 安全优先 - 模块化 SSH 配置 (`config.d/`),附带加固默认值 - 动态密钥管理 — 自动发现所有 `id_*` - macOS Keychain 集成 — 静默密码短语 - GPG 集成 — agent、签名、密钥管理 - Git 提交签名(SSH 密钥,兼容 GitHub) - 加密密钥备份 (age/GPG) - `ssh-audit` 安全健康检查 ### 🛠️ 60+ 工具集成 - 每个工具:`tools/TOOL.zsh` (代码) + `config/tools.d/TOOL.zsh` (配置) - 自动设置:克隆仓库、创建符号链接、生成配置 - 条件加载:未安装工具 = 不加载任何内容 - 无处不在的 FZF 集成 — 交互式选择 - `dot` CLI — 统一管理界面
### 🎨 Starship 提示符 — 3 个主题 - **Powerline** — 功能齐全,工作站默认 - **Minimal** — 简洁,适用于 SSH/Docker/远程 - **Nerd** — 信息量最大,适用于 VPS/Proxmox/K8s - 基于上下文(SSH、容器、VPS)自动选择 - 运行时切换:`dot theme minimal` ### 📦 自动克隆配置 - **nvim-enterprise** → `~/.config/nvim` - **wezterm-enterprise** → `~/.config/wezterm` - **ghostty-config** → `~/.config/ghostty` - **git-templates** → `dotfiles/config/git/git-templates` - 每次启动 Shell 时在后台更新
## 🌍 跨平台支持 | 平台 | 状态 | 包管理器 | 模块 | | :--------------- | :---: | :-------------------- | :--------------------- | | 🍎 macOS | ✅ | Homebrew | `platform/darwin.zsh` | | 🐧 Ubuntu / Debian | ✅ | apt | `platform/debian.zsh` | | 🎩 Fedora / RHEL | ✅ | dnf | `platform/fedora.zsh` | | 🏔️ Arch / Manjaro | ✅ | pacman / paru / yay | `platform/arch.zsh` | | 🪟 WSL / WSL2 | ✅ | apt / dnf / pacman | `platform/wsl.zsh` | | ❄️ NixOS | ✅ | nix | `core/01-platform.zsh` | ## 🐚 跨 Shell 支持 | Shell | 配置 | 别名 | 工具初始化 | 提示符 | | :---------- | :---------------- | :------------- | :-------------------------- | :------- | -------- | | **ZSH** | `shells/zsh/` | SSOT + tools.d | `tools/*.zsh` | Starship | | **Bash** | `shells/bash/` | SSOT 生成 | `shared/tools-init.sh` | Starship | | **Fish** | `shells/fish/` | SSOT 生成 | 原生 `| source` | Starship | | **Nushell** | `shells/nushell/` | 自定义 `def` | 预生成 `.nu` | Starship | ## 📦 [环境需求](requirements.md) | 依赖 | 版本 | 是否必须 | | :------------------------------------ | :-----: | :------: | | [Git](https://git-scm.com/) | `≥ 2.40` | ✅ | | [ZSH](https://www.zsh.org/) | `≥ 5.8` | ✅ | | [Nerd Font](https://www.nerdfonts.com/) | v3+ | ✅ | | [Homebrew](https://brew.sh/) (macOS) | latest | ⚠️ |
📋 安装所有工具 ``` brew install \ eza fzf bat fd ripgrep zoxide starship delta atuin mise direnv \ neovim git gh just tldr navi fastfetch btop dust duf topgrade \ thefuck yazi carapace lazygit lazydocker most \ jq yq gum age sd ouch glow xh hyperfine tokei procs \ tmux zellij k9s dive curlie bandwhich difftastic broot viddy lnav \ act trivy sops gnupg pinentry-mac git-lfs nushell # Essential brew install eza fzf bat fd ripgrep zoxide starship delta atuin mise direnv neovim git # DevOps brew install docker podman kubectl helm k9s lazygit lazydocker dive act trivy sops ansible # Utilities brew install gh just tldr navi fastfetch btop dust duf topgrade thefuck yazi carapace most # Data & HTTP brew install jq yq gum xh curlie # Security brew install age gnupg pinentry-mac git-lfs # Performance & Analysis brew install hyperfine tokei procs bandwhich difftastic # File & System brew install sd ouch glow broot viddy lnav # Multiplexers brew install tmux zellij # Shells brew install bash fish nushell # Terminals brew install --cask ghostty wezterm kitty alacritty ```
# Search nixpkgs dot nix clean # Garbage collect ``` ## 🎨 Starship 主题 三个上下文感知的主题,根据环境自动选择: | 主题 | 上下文 | 样式 | | :----------- | :---------------------------- | :------------------------------ | | **Powerline** | 工作站、桌面 | 圆角分段,完整信息 | | **Minimal** | SSH、Docker、远程 | 简洁双行,低带宽 | | **Nerd** | VPS、Proxmox、K8s | 最大信息密度 | ``` dot theme # Interactive FZF selector dot theme minimal # Direct switch dot theme preview # Preview all ``` 自动检测优先级: 1. `STARSHIP_THEME` 环境变量(手动覆盖) 2. Proxmox / Kubernetes / VPS → **Nerd** 3. SSH / Docker / Container → **Minimal** 4. 本地工作站 → **Powerline** ## 🛠️ 集成工具 ### 核心工具 | 工具 | 用途 | 配置 | | ---------------------------------------------- | ------------------- | ------------------------------ | | [eza](https://eza.rocks) | 现代版 `ls` | `config/tools.d/eza.zsh` | | [fzf](https://github.com/junegunn/fzf) | 模糊查找器 | `config/tools.d/fzf.zsh` | | [bat](https://github.com/sharkdp/bat) | 语法高亮 `cat` | `config/tools.d/bat.zsh` | | [fd](https://github.com/sharkdp/fd) | 现代版 `find` | `config/tools.d/fd.zsh` | | [ripgrep](https://github.com/BurntSushi/ripgrep) | 超快速 `grep` | `config/tools.d/ripgrep.zsh` | | [zoxide](https://github.com/ajeetdsouza/zoxide) | 智能 `cd` | `config/tools.d/zoxide.zsh` | | [starship](https://starship.rs) | 提示符(3 个主题) | `themes/starship-*.toml` | | [delta](https://github.com/dandavison/delta) | Git diff | `config/tools.d/delta.zsh` | | [atuin](https://atuin.sh) | Shell 历史记录 | `config/tools.d/atuin.zsh` | | [mise](https://mise.jdx.dev) | 运行时版本管理器 | `config/tools.d/mise.zsh` | | [jq](