<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans">
    <title>canxin&#x27;s blog - Linux</title>
    <subtitle>canxin 的博客</subtitle>
    <link rel="self" type="application/atom+xml" href="https://blog.cxits.cn/tags/linux/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://blog.cxits.cn"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-08-30T00:00:00+00:00</updated>
    <id>https://blog.cxits.cn/tags/linux/atom.xml</id>
    <entry xml:lang="zh-Hans">
        <title>canxin-zsh：把一套不打扰现有配置的 zsh 环境带到每台机器</title>
        <published>2026-08-30T00:00:00+00:00</published>
        <updated>2026-08-30T00:00:00+00:00</updated>
        
        <author>
          <name>
            canxin
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.cxits.cn/blog/canxin-zsh/"/>
        <id>https://blog.cxits.cn/blog/canxin-zsh/</id>
        
        <content type="html" xml:base="https://blog.cxits.cn/blog/canxin-zsh/">&lt;blockquote&gt;
&lt;p&gt;项目地址：&lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;canxin121&#x2F;canxin-zsh&quot;&gt;canxin121&#x2F;canxin-zsh&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;本文介绍项目的定位、安装后的使用体验和设计取舍。具体参数与最新平台支持情况请以仓库的 &lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;canxin121&#x2F;canxin-zsh&#x2F;blob&#x2F;main&#x2F;README.md&quot;&gt;README&lt;&#x2F;a&gt; 为准。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;很多人第一次整理 zsh 配置时，都会遇到两个相反的问题：要么把一份 &lt;code&gt;.zshrc&lt;&#x2F;code&gt; 直接复制到每台机器上，最后和系统环境、已有插件互相冲突；要么每换一台电脑，就重新手动安装 zsh、Oh My Zsh、主题、插件和各种命令行工具。&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;canxin-zsh&lt;&#x2F;code&gt; 想解决的是中间这件事：把一套可复用的 zsh 环境、默认工具和安装流程放在同一个仓库里，同时尽量尊重用户已经存在的配置。它可以在 macOS、Linux、WSL、MSYS2 和 Cygwin 中使用，并根据当前平台选择可用的包管理器。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;zhe-ge-cang-ku-dao-di-shi-shen-me&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#zhe-ge-cang-ku-dao-di-shi-shen-me&quot; aria-label=&quot;Anchor link for: zhe-ge-cang-ku-dao-di-shi-shen-me&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
这个仓库到底是什么&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;canxin-zsh&lt;&#x2F;code&gt; 不只是几份 dotfiles，也不是一个会接管整台电脑的配置管理器。它由三部分组成：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;home&#x2F;.zshrc&lt;&#x2F;code&gt; 和 &lt;code&gt;home&#x2F;.zprofile&lt;&#x2F;code&gt;：zsh 的入口配置；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;zsh&#x2F;rc&#x2F;common.zsh&lt;&#x2F;code&gt;：alias、工具检测、历史记录、Oh My Zsh 接入和更新函数；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;install.sh&lt;&#x2F;code&gt; 与 &lt;code&gt;install.ps1&lt;&#x2F;code&gt;：分别负责 POSIX shell 和 Windows PowerShell 场景的安装。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;安装器会把仓库作为一个可更新的 source checkout 保存下来，再让用户的 zsh 配置加载它。这样做的好处是，仓库更新时不需要把一整份新的 &lt;code&gt;.zshrc&lt;&#x2F;code&gt; 覆盖到用户家目录里，也不会因为某一台机器的路径不同而失效。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;an-zhuang-yi-hou-neng-de-dao-shen-me&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#an-zhuang-yi-hou-neng-de-dao-shen-me&quot; aria-label=&quot;Anchor link for: an-zhuang-yi-hou-neng-de-dao-shen-me&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
安装以后能得到什么&lt;&#x2F;h2&gt;
&lt;p&gt;普通全量安装、且原来的 zsh 配置为空时，得到的是一套可以直接工作的交互式 shell 环境。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;geng-you-xin-xi-liang-de-prompt&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#geng-you-xin-xi-liang-de-prompt&quot; aria-label=&quot;Anchor link for: geng-you-xin-xi-liang-de-prompt&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
更有信息量的 prompt&lt;&#x2F;h3&gt;
&lt;p&gt;默认会安装并使用 &lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;romkatv&#x2F;powerlevel10k&quot;&gt;Powerlevel10k&lt;&#x2F;a&gt;。提示符会展示当前目录、Git 分支和工作区状态，也会保留命令执行状态等有助于日常开发的信息。&lt;&#x2F;p&gt;
&lt;p&gt;如果用户已经选择了其他主题，或者家目录中已经有可读的 &lt;code&gt;.p10k.zsh&lt;&#x2F;code&gt;，安装器会优先保留用户自己的选择，不会强行换主题或覆盖 p10k 配置。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;oh-my-zsh-yu-chang-yong-cha-jian&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#oh-my-zsh-yu-chang-yong-cha-jian&quot; aria-label=&quot;Anchor link for: oh-my-zsh-yu-chang-yong-cha-jian&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
Oh My Zsh 与常用插件&lt;&#x2F;h3&gt;
&lt;p&gt;全新配置会使用 &lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ohmyzsh&#x2F;ohmyzsh&quot;&gt;Oh My Zsh&lt;&#x2F;a&gt;，并启用一组比较实用的基础插件：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git&lt;&#x2F;code&gt;：Git 命令别名和仓库提示；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;colored-man-pages&lt;&#x2F;code&gt;：让 man 文档更容易阅读；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;dirhistory&lt;&#x2F;code&gt;：使用快捷键浏览目录历史；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;extract&lt;&#x2F;code&gt;：用统一命令解压常见压缩文件；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;sudo&lt;&#x2F;code&gt;：快速为上一条命令补上 sudo。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;此外还会准备以下插件：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;zsh-completions&lt;&#x2F;code&gt;：补充更多命令的 Tab 补全；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;fzf-tab&lt;&#x2F;code&gt;：把补全候选项接入交互式选择；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;zsh-autosuggestions&lt;&#x2F;code&gt;：根据历史命令给出灰色建议；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;zsh-history-substring-search&lt;&#x2F;code&gt;：按输入内容搜索历史；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;zsh-syntax-highlighting&lt;&#x2F;code&gt;：对命令输入进行语法高亮。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;li-shi-ji-lu-he-mu-lu-dao-hang&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#li-shi-ji-lu-he-mu-lu-dao-hang&quot; aria-label=&quot;Anchor link for: li-shi-ji-lu-he-mu-lu-dao-hang&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
历史记录和目录导航&lt;&#x2F;h3&gt;
&lt;p&gt;在全新配置中，历史记录默认保留最多 50,000 条，并启用增量写入、跨 shell 共享和重复命令过滤。输入一部分命令后，按上下方向键可以在历史中搜索包含这段文字的命令。&lt;&#x2F;p&gt;
&lt;p&gt;目录操作也会启用一些适合交互式 shell 的选项：可以直接输入目录名进入目录，使用目录栈快速回到之前的位置，同时避免同一个目录被重复压入目录栈。&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;Ctrl-E&lt;&#x2F;code&gt; 会调用 zsh 的 &lt;code&gt;edit-command-line&lt;&#x2F;code&gt;，用编辑器打开当前正在输入的命令，适合编辑比较长的命令或多行脚本。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;fzf-sou-suo-gong-zuo-liu&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#fzf-sou-suo-gong-zuo-liu&quot; aria-label=&quot;Anchor link for: fzf-sou-suo-gong-zuo-liu&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
fzf 搜索工作流&lt;&#x2F;h3&gt;
&lt;p&gt;如果系统中安装了 &lt;code&gt;fzf&lt;&#x2F;code&gt;，配置会自动把它接入文件搜索、目录切换和补全预览。&lt;code&gt;fd&lt;&#x2F;code&gt; 或 &lt;code&gt;fdfind&lt;&#x2F;code&gt; 存在时，fzf 会使用它们查找隐藏文件并排除 &lt;code&gt;.git&lt;&#x2F;code&gt;；如果没有，就退回系统自带的 &lt;code&gt;find&lt;&#x2F;code&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;这意味着安装完成后，文件搜索、目录跳转和补全候选项都可以通过交互式筛选完成，而不必每次手写很长的 &lt;code&gt;find&lt;&#x2F;code&gt; 命令。没有安装 fzf 时，普通 Tab 补全和系统命令仍然可以正常使用。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;yi-zu-shi-ji-ke-yong-de-alias&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#yi-zu-shi-ji-ke-yong-de-alias&quot; aria-label=&quot;Anchor link for: yi-zu-shi-ji-ke-yong-de-alias&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
一组实际可用的 alias&lt;&#x2F;h3&gt;
&lt;p&gt;配置会根据当前机器上实际存在的命令自动选择 alias。下面这些命令是日常最容易用到的一组：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;l&lt;&#x2F;span&gt;&lt;span style=&quot;color: #2AA198;&quot;&gt; &#x2F; ls&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;       # 有 eza&#x2F;exa 时增强目录列表，否则保留系统 ls&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;ll&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;           # 详细列出文件、隐藏文件和 Git 状态&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;la&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;           # 列出隐藏文件&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;lt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;           # 以树状形式列出目录&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;catp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #2AA198;&quot;&gt; FILE&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;    # 有 bat&#x2F;batcat 时高亮并分页查看文件&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #2AA198;&quot;&gt; TEXT&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;    # 有 ripgrep 时使用 rg 搜索&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;top&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;          # 有 btop 时启动 btop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;lg&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;            # 有 lazygit 时启动 lazygit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;zreload&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;      # 重新加载 zsh 配置&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;zupdate-all&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;  # 更新 Oh My Zsh 和插件&#x2F;主题 checkout&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这些 alias 只会在同名 alias 或 function 尚不存在时定义。如果用户已经有自己的 &lt;code&gt;ls&lt;&#x2F;code&gt;、&lt;code&gt;grep&lt;&#x2F;code&gt; 或 &lt;code&gt;lg&lt;&#x2F;code&gt;，项目不会直接覆盖它们。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;zen-me-an-zhuang&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#zen-me-an-zhuang&quot; aria-label=&quot;Anchor link for: zen-me-an-zhuang&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
怎么安装&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;macos-linux-wsl-he-msys2&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#macos-linux-wsl-he-msys2&quot; aria-label=&quot;Anchor link for: macos-linux-wsl-he-msys2&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
macOS、Linux、WSL 和 MSYS2&lt;&#x2F;h3&gt;
&lt;p&gt;在对应的终端执行：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #CB4B16;&quot;&gt; -fsSL&lt;&#x2F;span&gt;&lt;span style=&quot;color: #2AA198;&quot;&gt; https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;canxin121&#x2F;canxin-zsh&#x2F;main&#x2F;install.sh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt; bash&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;安装器会自动检查并尝试补齐 zsh、Git、curl、CA 证书和默认命令行工具。远程命令本身需要当前环境已经有 &lt;code&gt;curl&lt;&#x2F;code&gt; 和 &lt;code&gt;bash&lt;&#x2F;code&gt;；如果需要先审查脚本，也可以 clone 后从本地运行：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #2AA198;&quot;&gt; clone https:&#x2F;&#x2F;github.com&#x2F;canxin121&#x2F;canxin-zsh.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #2AA198;&quot;&gt; canxin-zsh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;.&#x2F;install.sh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;windows-powershell&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#windows-powershell&quot; aria-label=&quot;Anchor link for: windows-powershell&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
Windows PowerShell&lt;&#x2F;h3&gt;
&lt;p&gt;原生 PowerShell 本身没有 zsh。已经安装 WSL、MSYS2 或 Cygwin 后，可以在 PowerShell 中使用项目提供的转发脚本：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;powershell&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;irm https:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&#x2F;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;raw.githubusercontent.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;canxin121&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;canxin&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;zsh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;main&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;install.ps1 &lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;|&lt;&#x2F;span&gt;&lt;span&gt; iex&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;它会优先使用 &lt;code&gt;wsl.exe&lt;&#x2F;code&gt;，其次使用 &lt;code&gt;bash.exe&lt;&#x2F;code&gt;。实际配置安装在哪个环境，取决于最终被调用的 WSL、MSYS2 或 Cygwin。这个命令不会自动安装 WSL，也不能让单独的 Git Bash 变成 zsh。&lt;&#x2F;p&gt;
&lt;p&gt;安装完成后，重新打开终端，或执行：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;exec&lt;&#x2F;span&gt;&lt;span style=&quot;color: #2AA198;&quot;&gt; zsh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;yi-lai-hui-zen-me-chu-li&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#yi-lai-hui-zen-me-chu-li&quot; aria-label=&quot;Anchor link for: yi-lai-hui-zen-me-chu-li&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
依赖会怎么处理&lt;&#x2F;h2&gt;
&lt;p&gt;这个项目不希望用户安装完后才发现一半功能因为缺命令而失效，所以普通安装会默认尝试准备下面这些内容。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;ji-chu-yun-xing-yi-lai&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#ji-chu-yun-xing-yi-lai&quot; aria-label=&quot;Anchor link for: ji-chu-yun-xing-yi-lai&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
基础运行依赖&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;zsh&lt;&#x2F;code&gt;：实际运行 shell；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;git&lt;&#x2F;code&gt;：下载仓库、Oh My Zsh、主题和插件；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;curl&lt;&#x2F;code&gt;：远程安装与获取内容；&lt;&#x2F;li&gt;
&lt;li&gt;CA 证书：确保 HTTPS 下载能够正常验证。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;mo-ren-ming-ling-xing-gong-ju-ji&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#mo-ren-ming-ling-xing-gong-ju-ji&quot; aria-label=&quot;Anchor link for: mo-ren-ming-ling-xing-gong-ju-ji&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
默认命令行工具集&lt;&#x2F;h3&gt;
&lt;p&gt;默认工具集包括 &lt;code&gt;fzf&lt;&#x2F;code&gt;、&lt;code&gt;ripgrep&lt;&#x2F;code&gt;、&lt;code&gt;fd&lt;&#x2F;code&gt;、&lt;code&gt;eza&lt;&#x2F;code&gt;、&lt;code&gt;bat&lt;&#x2F;code&gt;、&lt;code&gt;btop&lt;&#x2F;code&gt;、&lt;code&gt;lazygit&lt;&#x2F;code&gt; 和 &lt;code&gt;tldr&lt;&#x2F;code&gt;。不同系统的可执行文件名和软件包名可能不同，例如：&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;作用&lt;&#x2F;th&gt;&lt;th&gt;可能出现的命令&lt;&#x2F;th&gt;&lt;th&gt;常见软件包名&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;模糊搜索&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;fzf&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;fzf&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;文本搜索&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;rg&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;ripgrep&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;文件查找&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;fd&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;fdfind&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;fd&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;fd-find&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;目录列表&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;eza&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;exa&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;eza&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;文件查看&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;bat&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;batcat&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;bat&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;系统监控&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;btop&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;btop&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Git 终端界面&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;lazygit&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;lazygit&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;命令示例&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;tldr&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;tealdeer&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;工具集是普通安装的默认内容，不需要逐项选择。只有想要更轻量的安装时，才使用：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;.&#x2F;install.sh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #CB4B16;&quot;&gt; --minimal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;它会跳过默认工具集，但仍然尝试安装基础依赖。工具集中的单个软件包在某个发行版中不存在时，只会发出警告并继续；基础 shell 仍能工作。&lt;code&gt;zsh&lt;&#x2F;code&gt;、&lt;code&gt;git&lt;&#x2F;code&gt; 或 &lt;code&gt;curl&lt;&#x2F;code&gt; 这类必需命令在安装后仍缺失，则安装会停止。&lt;&#x2F;p&gt;
&lt;p&gt;安装器目前会识别 Homebrew、apt、dnf、yum、pacman、apk 和 zypper。macOS 没有 Homebrew 时不会静默安装 Homebrew；Cygwin 的系统包则需要通过 Cygwin 安装器维护。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;ta-ru-he-bi-mian-po-pi-yi-you-pei-zhi&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#ta-ru-he-bi-mian-po-pi-yi-you-pei-zhi&quot; aria-label=&quot;Anchor link for: ta-ru-he-bi-mian-po-pi-yi-you-pei-zhi&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
它如何避免破坏已有配置&lt;&#x2F;h2&gt;
&lt;p&gt;这是这个项目最重要的设计取舍：共享配置不能以“把用户的 &lt;code&gt;.zshrc&lt;&#x2F;code&gt; 换成我的版本”为代价。&lt;&#x2F;p&gt;
&lt;p&gt;安装器不会把仓库中的 &lt;code&gt;home&#x2F;.zshrc&lt;&#x2F;code&gt; 直接复制覆盖用户文件，而是在用户的 &lt;code&gt;~&#x2F;.zshrc&lt;&#x2F;code&gt; 和 &lt;code&gt;~&#x2F;.zprofile&lt;&#x2F;code&gt; 末尾维护一个可重复更新的区块：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;# &amp;gt;&amp;gt;&amp;gt; zsh-dotfiles managed block &amp;gt;&amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;# &amp;lt;&amp;lt;&amp;lt; zsh-dotfiles managed block &amp;lt;&amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;虽然仓库已经从 &lt;code&gt;zsh-dotfiles&lt;&#x2F;code&gt; 改名为 &lt;code&gt;canxin-zsh&lt;&#x2F;code&gt;，marker 仍然保留旧名称，这是为了让历史安装可以被新版本识别和更新，避免升级后加载两遍配置。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;xin-pei-zhi-he-yi-you-pei-zhi-de-qu-bie&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#xin-pei-zhi-he-yi-you-pei-zhi-de-qu-bie&quot; aria-label=&quot;Anchor link for: xin-pei-zhi-he-yi-you-pei-zhi-de-qu-bie&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
新配置和已有配置的区别&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;空配置会进入 bootstrap 模式，启用完整的默认历史、补全、目录导航、快捷键、Oh My Zsh 和主题；&lt;&#x2F;li&gt;
&lt;li&gt;非空配置会进入兼容集成模式，保留用户已有的主题、插件、历史选项、补全样式和快捷键；&lt;&#x2F;li&gt;
&lt;li&gt;已经加载 Oh My Zsh 时不会重复加载，也不会重设用户的 &lt;code&gt;ZSH_THEME&lt;&#x2F;code&gt; 和 &lt;code&gt;plugins&lt;&#x2F;code&gt;；&lt;&#x2F;li&gt;
&lt;li&gt;检测到 zinit、zplug、zgen、antigen、zimfw、sheldon、prezto、zcomet 等其他框架时，不会再额外启动 Oh My Zsh；&lt;&#x2F;li&gt;
&lt;li&gt;已有 alias、function 和可读的 Powerlevel10k 配置会优先保留；&lt;&#x2F;li&gt;
&lt;li&gt;普通 symlink 会保留，安装器会更新它指向的目标；如果 symlink 直接指向仓库 source 文件，会先安全解除这个自引用关系，避免递归加载。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;如果安装器确实需要修改已有配置，会先在下面的位置创建备份：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;~&#x2F;.config&#x2F;zsh-dotfiles&#x2F;backups&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;机器特定的设置可以放在：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;~&#x2F;.zprofile.local   # PATH、SDK、代理和登录 shell 设置&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;~&#x2F;.zshrc.local      # 本机 alias、函数和交互式设置&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这些文件不会被仓库覆盖，也不应该提交到公开仓库。对于空配置，它们会自动加载；对于已有非空配置，安装器默认不额外插入加载语句，以免改变原来的加载顺序，可以由用户自行 source。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;an-zhuang-hou-ru-he-jian-cha-he-geng-xin&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#an-zhuang-hou-ru-he-jian-cha-he-geng-xin&quot; aria-label=&quot;Anchor link for: an-zhuang-hou-ru-he-jian-cha-he-geng-xin&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
安装后如何检查和更新&lt;&#x2F;h2&gt;
&lt;p&gt;本地 clone 的项目可以运行：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;bin&#x2F;zsh-doctor&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;远程安装默认把 source checkout 放在：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;${XDG_DATA_HOME:-$HOME&#x2F;.local&#x2F;share}&#x2F;canxin-zsh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;因此也可以直接执行：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;${&lt;&#x2F;span&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;XDG_DATA_HOME&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;:-&lt;&#x2F;span&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;$HOME&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;.local&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;share&lt;&#x2F;span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;&#x2F;canxin-zsh&#x2F;bin&#x2F;zsh-doctor&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;诊断工具会检查 zsh、Git、默认工具集以及 &lt;code&gt;code&lt;&#x2F;code&gt; 命令是否存在，方便判断某个 alias 或增强功能为什么没有启用。&lt;&#x2F;p&gt;
&lt;p&gt;配置加载后，可以使用：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;zupdate-all&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;它会尝试更新 Oh My Zsh 和 &lt;code&gt;$ZSH_CUSTOM&lt;&#x2F;code&gt; 下的 Git 插件&#x2F;主题 checkout。如果 &lt;code&gt;$ZSH_CUSTOM&lt;&#x2F;code&gt; 里还有用户自己放入的 Git checkout，它们也可能被更新；如果系统有 Homebrew，还会执行 &lt;code&gt;brew update&lt;&#x2F;code&gt; 和 &lt;code&gt;brew upgrade&lt;&#x2F;code&gt;。因此这个命令适合明确希望更新整套开发环境时使用。&lt;&#x2F;p&gt;
&lt;p&gt;安装阶段的更新选项则更细分：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #839496; background-color: #002B36;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;.&#x2F;install.sh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #CB4B16;&quot;&gt; --update&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;         # 更新远程地址匹配的依赖 checkout&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;.&#x2F;install.sh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #CB4B16;&quot;&gt; --update-source&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;  # 更新远程安装管理的 canxin-zsh source checkout&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #268BD2;&quot;&gt;.&#x2F;install.sh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #CB4B16;&quot;&gt; --dry-run&lt;&#x2F;span&gt;&lt;span style=&quot;color: #586E75;font-style: italic;&quot;&gt;        # 在本地 checkout 中只查看计划，不写配置&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;zhi-chi-de-ping-tai&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#zhi-chi-de-ping-tai&quot; aria-label=&quot;Anchor link for: zhi-chi-de-ping-tai&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
支持的平台&lt;&#x2F;h2&gt;
&lt;p&gt;项目会根据环境使用对应的系统包管理器：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;macOS：优先使用已经安装的 Homebrew，也可以使用系统已有的 zsh 和 curl；&lt;&#x2F;li&gt;
&lt;li&gt;Debian、Ubuntu、WSL：使用 &lt;code&gt;apt-get&lt;&#x2F;code&gt;；&lt;&#x2F;li&gt;
&lt;li&gt;Fedora、RHEL：使用 &lt;code&gt;dnf&lt;&#x2F;code&gt; 或 &lt;code&gt;yum&lt;&#x2F;code&gt;；&lt;&#x2F;li&gt;
&lt;li&gt;Arch Linux 和 MSYS2：使用 &lt;code&gt;pacman&lt;&#x2F;code&gt;；&lt;&#x2F;li&gt;
&lt;li&gt;Alpine Linux：使用 &lt;code&gt;apk&lt;&#x2F;code&gt;；&lt;&#x2F;li&gt;
&lt;li&gt;openSUSE：使用 &lt;code&gt;zypper&lt;&#x2F;code&gt;；&lt;&#x2F;li&gt;
&lt;li&gt;Cygwin：先用 Cygwin 安装器准备 &lt;code&gt;git&lt;&#x2F;code&gt;、&lt;code&gt;curl&lt;&#x2F;code&gt; 和 &lt;code&gt;zsh&lt;&#x2F;code&gt;，再运行项目安装器。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;原生 Windows PowerShell 和单独的 Git Bash 都不是 zsh 运行环境。Windows 用户应把 WSL 作为首选，或者使用已经安装 zsh 的 MSYS2&#x2F;Cygwin。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;zhe-ge-xiang-mu-wei-shen-me-zhi-de-dan-du-zuo-yi-ge-an-zhuang-qi&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#zhe-ge-xiang-mu-wei-shen-me-zhi-de-dan-du-zuo-yi-ge-an-zhuang-qi&quot; aria-label=&quot;Anchor link for: zhe-ge-xiang-mu-wei-shen-me-zhi-de-dan-du-zuo-yi-ge-an-zhuang-qi&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
这个项目为什么值得单独做一个安装器&lt;&#x2F;h2&gt;
&lt;p&gt;如果只是把几个配置文件放进 Git 仓库，跨平台时很快就会遇到这些问题：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;macOS、Linux 和 MSYS2 的包管理器完全不同；&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;fd&lt;&#x2F;code&gt;、&lt;code&gt;bat&lt;&#x2F;code&gt; 等工具在 Debian 系统上的命令名可能与 macOS 不同；&lt;&#x2F;li&gt;
&lt;li&gt;有些机器已经有自己的 Oh My Zsh 或其他框架；&lt;&#x2F;li&gt;
&lt;li&gt;用户的 &lt;code&gt;.zshrc&lt;&#x2F;code&gt; 里可能已经有大量 alias、函数和本机变量；&lt;&#x2F;li&gt;
&lt;li&gt;通过 &lt;code&gt;curl | bash&lt;&#x2F;code&gt; 安装时，仓库 source 不能依赖当前目录存在；&lt;&#x2F;li&gt;
&lt;li&gt;symlink、&lt;code&gt;ZDOTDIR&lt;&#x2F;code&gt; 和旧版本安装路径都可能造成重复加载或覆盖。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;安装器把这些判断集中处理了：它会根据命令是否存在选择增强功能，根据配置内容选择 bootstrap 或 integrate 模式，根据远程地址决定是否允许更新，并在写入前留下备份。重复运行安装器时，已有 managed block 会被更新，而不是不断追加相同配置。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;kua-ping-tai-yan-zheng&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#kua-ping-tai-yan-zheng&quot; aria-label=&quot;Anchor link for: kua-ping-tai-yan-zheng&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
跨平台验证&lt;&#x2F;h2&gt;
&lt;p&gt;这不是只在一台 Mac 上能工作的个人配置。仓库的 GitHub Actions 会在 Ubuntu、macOS 和 Windows&#x2F;MSYS2 上运行 shell 语法检查、ShellCheck、隔离安装测试和真实依赖安装 smoke test；非 Pull Request 事件还会验证已经发布的一键安装脚本是否能够完成 bootstrap。&lt;&#x2F;p&gt;
&lt;p&gt;因此，项目更关注“安装器能否在不同环境中安全完成初始化”，而不只是 prompt 在作者自己的机器上看起来是否正常。可以在 &lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;canxin121&#x2F;canxin-zsh&#x2F;actions&quot;&gt;Actions 页面&lt;&#x2F;a&gt; 查看每次提交的验证结果。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;an-quan-ti-shi&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#an-quan-ti-shi&quot; aria-label=&quot;Anchor link for: an-quan-ti-shi&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
安全提示&lt;&#x2F;h2&gt;
&lt;p&gt;远程一键安装本质上会下载并执行仓库中的 shell 脚本。在敏感环境中，建议先 clone 并阅读 &lt;a class=&quot;external&quot; rel=&quot;noopener nofollow noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;canxin121&#x2F;canxin-zsh&#x2F;blob&#x2F;main&#x2F;install.sh&quot;&gt;install.sh&lt;&#x2F;a&gt;，再决定是否执行。安装器需要系统权限时只调用已有的 &lt;code&gt;sudo&lt;&#x2F;code&gt; 或 &lt;code&gt;doas&lt;&#x2F;code&gt;，不会把密码写入文件。&lt;&#x2F;p&gt;
&lt;p&gt;公开仓库中的所有脚本、配置和提交历史都应视为任何人可读。API token、密码、私钥、公司内部路径和代理凭据应该放在本机的 local 文件或专门的秘密管理工具中，而不是放进仓库。&lt;code&gt;.gitignore&lt;&#x2F;code&gt; 可以降低误提交概率，但不能代替秘密管理，也不能抹掉已经进入 Git 历史的敏感内容。&lt;&#x2F;p&gt;
&lt;p&gt;如果你正在寻找一套“装一次、换机器时少折腾、又不希望接管原有 shell 配置”的 zsh 起点，&lt;code&gt;canxin-zsh&lt;&#x2F;code&gt; 就是为这个场景准备的。&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
