<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>模組零：Dotfile 心智模型 on Tarragon</title><link>https://tarrragon.github.io/blog/linux/dotfile/00-dotfile-mindset/</link><description>Recent content in 模組零：Dotfile 心智模型 on Tarragon</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Tarragon (CC BY 4.0)</copyright><lastBuildDate>Mon, 29 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tarrragon.github.io/blog/linux/dotfile/00-dotfile-mindset/index.xml" rel="self" type="application/rss+xml"/><item><title>環境可重現性與配置分類</title><link>https://tarrragon.github.io/blog/linux/dotfile/00-dotfile-mindset/environment-reproducibility/</link><pubDate>Mon, 29 Jun 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/linux/dotfile/00-dotfile-mindset/environment-reproducibility/</guid><description>&lt;p>Dotfile 管理的核心能力是&lt;strong>環境可重現性&lt;/strong>：把個人開發環境的配置狀態變成版控下的代碼，讓任何一台空白機器都能用一份 Git repo 還原成你熟悉的工作桌面。&lt;/p>
&lt;h2 id="什麼是-dotfile">什麼是 Dotfile&lt;/h2>
&lt;p>Unix 系統用檔名開頭的 &lt;code>.&lt;/code> 標記隱藏檔。shell 配置（&lt;code>.bashrc&lt;/code>、&lt;code>.zshrc&lt;/code>）、Git 設定（&lt;code>.gitconfig&lt;/code>）、SSH 設定（&lt;code>.ssh/config&lt;/code>）、以及 &lt;code>~/.config/&lt;/code> 底下各種工具的配置目錄，都屬於這個範疇。這些檔案決定了你的工作環境怎麼運作：shell 的 prompt 長什麼樣、alias 有哪些、editor 用什麼 keymap、terminal 的配色方案、視窗管理器怎麼排列畫面。&lt;/p>
&lt;p>「dotfile 管理」指的是把這些散落在家目錄各處的配置檔&lt;strong>集中到一個 Git repo&lt;/strong>，建立版本歷史、可以跨機器同步、可以在新環境一鍵部署。跟手動備份的差異在於：備份是搬檔案，dotfile 管理是建立一套可重複執行的環境建構流程。&lt;/p>
&lt;h2 id="為什麼要管理-dotfile">為什麼要管理 Dotfile&lt;/h2>
&lt;p>開發環境是累積出來的。今天加一個 alias、明天改一個 Git 設定、下週裝了一個 terminal 外掛調了字型。這些微調加起來就是「你順手的工作環境」，但因為都是零碎的小改動，很少有人會主動記錄。&lt;/p>
&lt;p>問題在累積到一定程度後、環境需要重建的那一刻才會浮出來：&lt;/p>
&lt;p>&lt;strong>換機器&lt;/strong>。拿到新筆電，開始從零設定。裝完 shell、editor、terminal，發現少了一堆 alias 和 function，但想不起來之前到底加了哪些。花兩天勉強恢復到七八成，剩下的在未來幾週慢慢「撞到才發現少了」。&lt;/p>
&lt;p>&lt;strong>設備故障或遺失&lt;/strong>。公司配的筆電硬碟壞了。如果配置沒有外部副本，那台機器上所有的自訂設定（有些可能花了半年慢慢調出來的）全部歸零。復原速度直接取決於「你有沒有把配置存在機器以外的地方」。&lt;/p>
&lt;p>&lt;strong>在 VM 或容器裡重現環境&lt;/strong>。想在虛擬機裡測試一套 Linux 桌面（例如 Hyprland），或在 Docker 容器裡重現自己的 shell 環境做 CI 除錯。沒有版控的配置，就得手動複製貼上，還要記住哪些檔案在哪個路徑。&lt;/p>
&lt;p>&lt;strong>跨機器一致性&lt;/strong>。同時用筆電、桌機、遠端伺服器，希望每台機器的 shell 行為、Git 設定、editor 快捷鍵都一致。手動同步的成本隨機器數量線性增長，而且很容易漏改某一台，導致操作習慣在不同機器間不一致。&lt;/p>
&lt;p>這些場景的共通點是：&lt;strong>配置的價值在累積，但累積的前提是有記錄&lt;/strong>。沒有記錄的累積，只是暫存在某一台機器上的隱性知識，機器一換就歸零。&lt;/p>
&lt;h2 id="哪些東西應該建立-dotfile">哪些東西應該建立 Dotfile&lt;/h2>
&lt;p>依配置的普遍性和適用場景，分成三層來判斷：&lt;/p>
&lt;h3 id="核心層幾乎所有開發者都該管的">核心層：幾乎所有開發者都該管的&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Shell 配置&lt;/strong>（&lt;code>.zshrc&lt;/code> / &lt;code>.bashrc&lt;/code>）：alias、function、PATH、prompt、completion 設定。這是最高頻修改、也最容易累積隱性知識的地方。&lt;/li>
&lt;li>&lt;strong>Git 配置&lt;/strong>（&lt;code>.gitconfig&lt;/code>）：使用者名稱、email、預設 editor、alias（&lt;code>git lg&lt;/code> = &lt;code>git log --oneline --graph&lt;/code>）、diff/merge tool。&lt;/li>
&lt;li>&lt;strong>SSH 配置&lt;/strong>（&lt;code>.ssh/config&lt;/code>）：Host 別名、ProxyJump 跳板設定、每台主機的 IdentityFile 指定。注意：&lt;strong>config 檔進 repo，私鑰不進 repo&lt;/strong>。&lt;/li>
&lt;li>&lt;strong>Editor 配置&lt;/strong>：&lt;code>.vimrc&lt;/code>（Vim）、&lt;code>~/.config/nvim/&lt;/code>（Neovim）、VS Code 的 &lt;code>settings.json&lt;/code> / &lt;code>keybindings.json&lt;/code>。&lt;/li>
&lt;/ul>
&lt;h3 id="工具層依個人工具鏈而定">工具層：依個人工具鏈而定&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Terminal multiplexer&lt;/strong>：tmux（&lt;code>.tmux.conf&lt;/code>）、zellij（&lt;code>~/.config/zellij/&lt;/code>）的面板配置、快捷鍵、狀態列。&lt;/li>
&lt;li>&lt;strong>Terminal emulator&lt;/strong>：Alacritty、WezTerm、Kitty 的字型、配色、快捷鍵設定。&lt;/li>
&lt;li>&lt;strong>套件清單&lt;/strong>：macOS 的 &lt;code>Brewfile&lt;/code>（&lt;code>brew bundle dump&lt;/code>）、Arch 的 &lt;code>pacman -Qqe &amp;gt; pkglist.txt&lt;/code>。這份清單讓新機器知道該裝哪些軟體。&lt;/li>
&lt;li>&lt;strong>開發工具的全域配置&lt;/strong>：&lt;code>.npmrc&lt;/code>、&lt;code>.cargo/config.toml&lt;/code>、&lt;code>.pypirc&lt;/code> 等。但要注意區分：&lt;code>.eslintrc&lt;/code> / &lt;code>.prettierrc&lt;/code> 這類通常跟著&lt;strong>專案&lt;/strong> repo 走（每個專案可能規則不同），不跟著人走。&lt;/li>
&lt;/ul>
&lt;h3 id="桌面層linux-桌面環境才需要">桌面層：Linux 桌面環境才需要&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Window manager&lt;/strong>：Hyprland（&lt;code>~/.config/hypr/&lt;/code>）、i3（&lt;code>~/.config/i3/&lt;/code>）、sway 的配置。&lt;/li>
&lt;li>&lt;strong>桌面元件&lt;/strong>：狀態列（waybar）、應用程式啟動器（rofi / wofi）、通知服務（mako / dunst）、鎖屏（swaylock / hyprlock）。&lt;/li>
&lt;li>&lt;strong>主題與配色&lt;/strong>：GTK / Qt 主題設定、游標主題、字型配置。&lt;/li>
&lt;/ul>
&lt;h3 id="判讀準則">判讀準則&lt;/h3>
&lt;p>區分一個配置該不該進 dotfile repo，核心問題是：&lt;strong>這個設定是跟著人走，還是跟著專案走？&lt;/strong>&lt;/p>
&lt;p>跟著人走的（不管開哪個專案都要用的）→ 進 dotfile repo。跟著專案走的（專案 A 用 ESLint、專案 B 用 Biome）→ 留在專案 repo。&lt;/p>
&lt;h3 id="不該進-dotfile-repo-的">不該進 Dotfile Repo 的&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>私鑰、API key、token、密碼&lt;/strong>。用 &lt;code>.gitignore&lt;/code> 排除，敏感資訊放 secret manager 或加密管理（具體做法見&lt;a href="https://tarrragon.github.io/blog/linux/dotfile/08-sync-bootstrap/sync-strategy-secret/" data-link-title="跨機器同步、Secret 管理與環境重建流程" data-link-desc="多台機器的 dotfile 怎麼同步、哪些東西不該進 repo 時回來讀">同步與 Secret 管理&lt;/a>）。&lt;/li>
&lt;li>&lt;strong>暫存檔、cache、log&lt;/strong>。&lt;code>.zsh_history&lt;/code> 很大且含敏感指令；各種工具的 cache 目錄是 generated 檔案，重建時自動產生。&lt;/li>
&lt;li>&lt;strong>OS 層級的二進位設定&lt;/strong>。macOS 的 plist 可以選擇性管理（&lt;code>defaults write&lt;/code> 指令可以版控），但整個 &lt;code>~/Library/Preferences/&lt;/code> 不適合直接丟進 Git——檔案格式不穩定、diff 不可讀、很多是應用程式自動產生的。&lt;/li>
&lt;/ul></description><content:encoded><![CDATA[<p>Dotfile 管理的核心能力是<strong>環境可重現性</strong>：把個人開發環境的配置狀態變成版控下的代碼，讓任何一台空白機器都能用一份 Git repo 還原成你熟悉的工作桌面。</p>
<h2 id="什麼是-dotfile">什麼是 Dotfile</h2>
<p>Unix 系統用檔名開頭的 <code>.</code> 標記隱藏檔。shell 配置（<code>.bashrc</code>、<code>.zshrc</code>）、Git 設定（<code>.gitconfig</code>）、SSH 設定（<code>.ssh/config</code>）、以及 <code>~/.config/</code> 底下各種工具的配置目錄，都屬於這個範疇。這些檔案決定了你的工作環境怎麼運作：shell 的 prompt 長什麼樣、alias 有哪些、editor 用什麼 keymap、terminal 的配色方案、視窗管理器怎麼排列畫面。</p>
<p>「dotfile 管理」指的是把這些散落在家目錄各處的配置檔<strong>集中到一個 Git repo</strong>，建立版本歷史、可以跨機器同步、可以在新環境一鍵部署。跟手動備份的差異在於：備份是搬檔案，dotfile 管理是建立一套可重複執行的環境建構流程。</p>
<h2 id="為什麼要管理-dotfile">為什麼要管理 Dotfile</h2>
<p>開發環境是累積出來的。今天加一個 alias、明天改一個 Git 設定、下週裝了一個 terminal 外掛調了字型。這些微調加起來就是「你順手的工作環境」，但因為都是零碎的小改動，很少有人會主動記錄。</p>
<p>問題在累積到一定程度後、環境需要重建的那一刻才會浮出來：</p>
<p><strong>換機器</strong>。拿到新筆電，開始從零設定。裝完 shell、editor、terminal，發現少了一堆 alias 和 function，但想不起來之前到底加了哪些。花兩天勉強恢復到七八成，剩下的在未來幾週慢慢「撞到才發現少了」。</p>
<p><strong>設備故障或遺失</strong>。公司配的筆電硬碟壞了。如果配置沒有外部副本，那台機器上所有的自訂設定（有些可能花了半年慢慢調出來的）全部歸零。復原速度直接取決於「你有沒有把配置存在機器以外的地方」。</p>
<p><strong>在 VM 或容器裡重現環境</strong>。想在虛擬機裡測試一套 Linux 桌面（例如 Hyprland），或在 Docker 容器裡重現自己的 shell 環境做 CI 除錯。沒有版控的配置，就得手動複製貼上，還要記住哪些檔案在哪個路徑。</p>
<p><strong>跨機器一致性</strong>。同時用筆電、桌機、遠端伺服器，希望每台機器的 shell 行為、Git 設定、editor 快捷鍵都一致。手動同步的成本隨機器數量線性增長，而且很容易漏改某一台，導致操作習慣在不同機器間不一致。</p>
<p>這些場景的共通點是：<strong>配置的價值在累積，但累積的前提是有記錄</strong>。沒有記錄的累積，只是暫存在某一台機器上的隱性知識，機器一換就歸零。</p>
<h2 id="哪些東西應該建立-dotfile">哪些東西應該建立 Dotfile</h2>
<p>依配置的普遍性和適用場景，分成三層來判斷：</p>
<h3 id="核心層幾乎所有開發者都該管的">核心層：幾乎所有開發者都該管的</h3>
<ul>
<li><strong>Shell 配置</strong>（<code>.zshrc</code> / <code>.bashrc</code>）：alias、function、PATH、prompt、completion 設定。這是最高頻修改、也最容易累積隱性知識的地方。</li>
<li><strong>Git 配置</strong>（<code>.gitconfig</code>）：使用者名稱、email、預設 editor、alias（<code>git lg</code> = <code>git log --oneline --graph</code>）、diff/merge tool。</li>
<li><strong>SSH 配置</strong>（<code>.ssh/config</code>）：Host 別名、ProxyJump 跳板設定、每台主機的 IdentityFile 指定。注意：<strong>config 檔進 repo，私鑰不進 repo</strong>。</li>
<li><strong>Editor 配置</strong>：<code>.vimrc</code>（Vim）、<code>~/.config/nvim/</code>（Neovim）、VS Code 的 <code>settings.json</code> / <code>keybindings.json</code>。</li>
</ul>
<h3 id="工具層依個人工具鏈而定">工具層：依個人工具鏈而定</h3>
<ul>
<li><strong>Terminal multiplexer</strong>：tmux（<code>.tmux.conf</code>）、zellij（<code>~/.config/zellij/</code>）的面板配置、快捷鍵、狀態列。</li>
<li><strong>Terminal emulator</strong>：Alacritty、WezTerm、Kitty 的字型、配色、快捷鍵設定。</li>
<li><strong>套件清單</strong>：macOS 的 <code>Brewfile</code>（<code>brew bundle dump</code>）、Arch 的 <code>pacman -Qqe &gt; pkglist.txt</code>。這份清單讓新機器知道該裝哪些軟體。</li>
<li><strong>開發工具的全域配置</strong>：<code>.npmrc</code>、<code>.cargo/config.toml</code>、<code>.pypirc</code> 等。但要注意區分：<code>.eslintrc</code> / <code>.prettierrc</code> 這類通常跟著<strong>專案</strong> repo 走（每個專案可能規則不同），不跟著人走。</li>
</ul>
<h3 id="桌面層linux-桌面環境才需要">桌面層：Linux 桌面環境才需要</h3>
<ul>
<li><strong>Window manager</strong>：Hyprland（<code>~/.config/hypr/</code>）、i3（<code>~/.config/i3/</code>）、sway 的配置。</li>
<li><strong>桌面元件</strong>：狀態列（waybar）、應用程式啟動器（rofi / wofi）、通知服務（mako / dunst）、鎖屏（swaylock / hyprlock）。</li>
<li><strong>主題與配色</strong>：GTK / Qt 主題設定、游標主題、字型配置。</li>
</ul>
<h3 id="判讀準則">判讀準則</h3>
<p>區分一個配置該不該進 dotfile repo，核心問題是：<strong>這個設定是跟著人走，還是跟著專案走？</strong></p>
<p>跟著人走的（不管開哪個專案都要用的）→ 進 dotfile repo。跟著專案走的（專案 A 用 ESLint、專案 B 用 Biome）→ 留在專案 repo。</p>
<h3 id="不該進-dotfile-repo-的">不該進 Dotfile Repo 的</h3>
<ul>
<li><strong>私鑰、API key、token、密碼</strong>。用 <code>.gitignore</code> 排除，敏感資訊放 secret manager 或加密管理（具體做法見<a href="/blog/linux/dotfile/08-sync-bootstrap/sync-strategy-secret/" data-link-title="跨機器同步、Secret 管理與環境重建流程" data-link-desc="多台機器的 dotfile 怎麼同步、哪些東西不該進 repo 時回來讀">同步與 Secret 管理</a>）。</li>
<li><strong>暫存檔、cache、log</strong>。<code>.zsh_history</code> 很大且含敏感指令；各種工具的 cache 目錄是 generated 檔案，重建時自動產生。</li>
<li><strong>OS 層級的二進位設定</strong>。macOS 的 plist 可以選擇性管理（<code>defaults write</code> 指令可以版控），但整個 <code>~/Library/Preferences/</code> 不適合直接丟進 Git——檔案格式不穩定、diff 不可讀、很多是應用程式自動產生的。</li>
</ul>
]]></content:encoded></item><item><title>Dotfile 跟 Infra IaC 的平行關係</title><link>https://tarrragon.github.io/blog/linux/dotfile/00-dotfile-mindset/dotfile-iac-parallel/</link><pubDate>Mon, 29 Jun 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/linux/dotfile/00-dotfile-mindset/dotfile-iac-parallel/</guid><description>&lt;p>&lt;a href="https://tarrragon.github.io/blog/infra/" data-link-title="Infra 基礎設施建置指南" data-link-desc="從零循序漸進把雲端基礎設施做起來 — IaC、身分憑證、網路地基、環境分離、核心服務、可觀測性、自動化 review 與治理習慣，含怎麼在組織內推動">Infra 基礎設施建置指南&lt;/a>教的是用 Terraform 或 OpenTofu 把雲端資源（VPC、IAM role、EC2 instance）寫成代碼，讓基礎設施可重現、可 review、可回滾。Dotfile 做的事在概念上完全平行：把個人工作環境（shell、editor、terminal、window manager）寫成代碼，達成同樣的可重現性。&lt;/p>
&lt;h2 id="共用的核心原則">共用的核心原則&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>宣告式&lt;/strong>：描述「環境應該長什麼樣」，而非「操作了哪些步驟」。Terraform 宣告「要有一個 VPC、CIDR 是 10.0.0.0/16」；dotfile 宣告「zsh 的 prompt 格式是這樣、alias ll 對應 ls -la」。&lt;/li>
&lt;li>&lt;strong>版控下的變更歷史&lt;/strong>：誰改了什麼、什麼時候改的、為什麼改，都在 Git log 裡。環境出問題時可以回溯到「上一次正常的狀態」是哪個 commit。&lt;/li>
&lt;li>&lt;strong>可 review&lt;/strong>：改了一個 shell function，diff 清楚可讀。跟在 terminal 裡直接 export 一個變數、下次重開就忘了相比，版控下的改動有跡可循。&lt;/li>
&lt;/ul>
&lt;h2 id="差異">差異&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>維度&lt;/th>
 &lt;th>Infra IaC&lt;/th>
 &lt;th>Dotfile&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>管理對象&lt;/td>
 &lt;td>組織的雲端資源&lt;/td>
 &lt;td>個人的工作桌面&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>State 管理&lt;/td>
 &lt;td>Remote backend + lock 機制（防並行衝突）&lt;/td>
 &lt;td>通常只用 Git，沒有額外 state file&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>生效方式&lt;/td>
 &lt;td>&lt;code>terraform plan&lt;/code> → &lt;code>terraform apply&lt;/code> 兩步&lt;/td>
 &lt;td>多數改完 source 即生效，或重開 terminal 生效&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>影響範圍&lt;/td>
 &lt;td>改錯可能影響 production 服務&lt;/td>
 &lt;td>改錯最多影響自己的工作環境&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>協作需求&lt;/td>
 &lt;td>團隊共用、需要 PR review&lt;/td>
 &lt;td>通常個人維護，PR review 是可選的&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>這個平行不只是比喻。&lt;a href="https://tarrragon.github.io/blog/linux/dotfile/09-team-environment/" data-link-title="模組九：從個人到團隊" data-link-desc="個人 dotfile 管理的思想要延伸到團隊開發環境標準化時回來讀 — devcontainer、nix、商業環境配置管理">從個人到團隊&lt;/a>會教怎麼把 dotfile 的思想正式擴展到團隊環境——devcontainer 把「開發環境應該長什麼樣」寫成宣告式配置，讓新人 clone repo 就能拿到一致的開發環境，這正是 IaC 思想從組織 infra 往個人工作桌面延伸的具體產物。&lt;/p>
&lt;h2 id="dotfile-是重建指令不是備份">Dotfile 是重建指令，不是備份&lt;/h2>
&lt;p>這是最重要的心智模型區分。Dotfile repo 的目標不是「把舊電腦的所有檔案搬到新電腦」（那是備份工具的工作），而是「一份能在空白機器上重建工作環境的指令集」。&lt;/p>
&lt;p>這個思維跟 Docker 的哲學一致：Docker image 透過 Dockerfile「描述如何重建」環境，而不是「對一台跑著的伺服器拍快照」。Dotfile repo 也是——它記錄的是「你的環境應該長什麼樣」的宣告，不是「你的機器上現在有什麼」的快照。&lt;/p>
&lt;p>這個區分決定了 repo 裡該放什麼：&lt;/p>
&lt;ul>
&lt;li>放進去的：&lt;strong>宣告式的配置檔&lt;/strong>（shell config、editor config、WM config）、&lt;strong>套件清單&lt;/strong>（Brewfile、pacman list）、&lt;strong>安裝腳本&lt;/strong>（&lt;code>install.sh&lt;/code>，用來在新機器上自動化部署流程）。&lt;/li>
&lt;li>不放的：&lt;strong>暫存狀態&lt;/strong>（shell history、undo file、session file）、&lt;strong>generated 產物&lt;/strong>（plugin 的 compiled cache）、&lt;strong>大型二進位檔&lt;/strong>（字型檔案可以用套件管理器裝，不用放 repo）。&lt;/li>
&lt;/ul>
&lt;p>維持「重建指令」的純度，repo 才能保持輕量、diff 可讀、跨機器部署不會帶進不必要的狀態。&lt;/p></description><content:encoded><![CDATA[<p><a href="/blog/infra/" data-link-title="Infra 基礎設施建置指南" data-link-desc="從零循序漸進把雲端基礎設施做起來 — IaC、身分憑證、網路地基、環境分離、核心服務、可觀測性、自動化 review 與治理習慣，含怎麼在組織內推動">Infra 基礎設施建置指南</a>教的是用 Terraform 或 OpenTofu 把雲端資源（VPC、IAM role、EC2 instance）寫成代碼，讓基礎設施可重現、可 review、可回滾。Dotfile 做的事在概念上完全平行：把個人工作環境（shell、editor、terminal、window manager）寫成代碼，達成同樣的可重現性。</p>
<h2 id="共用的核心原則">共用的核心原則</h2>
<ul>
<li><strong>宣告式</strong>：描述「環境應該長什麼樣」，而非「操作了哪些步驟」。Terraform 宣告「要有一個 VPC、CIDR 是 10.0.0.0/16」；dotfile 宣告「zsh 的 prompt 格式是這樣、alias ll 對應 ls -la」。</li>
<li><strong>版控下的變更歷史</strong>：誰改了什麼、什麼時候改的、為什麼改，都在 Git log 裡。環境出問題時可以回溯到「上一次正常的狀態」是哪個 commit。</li>
<li><strong>可 review</strong>：改了一個 shell function，diff 清楚可讀。跟在 terminal 裡直接 export 一個變數、下次重開就忘了相比，版控下的改動有跡可循。</li>
</ul>
<h2 id="差異">差異</h2>
<table>
  <thead>
      <tr>
          <th>維度</th>
          <th>Infra IaC</th>
          <th>Dotfile</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>管理對象</td>
          <td>組織的雲端資源</td>
          <td>個人的工作桌面</td>
      </tr>
      <tr>
          <td>State 管理</td>
          <td>Remote backend + lock 機制（防並行衝突）</td>
          <td>通常只用 Git，沒有額外 state file</td>
      </tr>
      <tr>
          <td>生效方式</td>
          <td><code>terraform plan</code> → <code>terraform apply</code> 兩步</td>
          <td>多數改完 source 即生效，或重開 terminal 生效</td>
      </tr>
      <tr>
          <td>影響範圍</td>
          <td>改錯可能影響 production 服務</td>
          <td>改錯最多影響自己的工作環境</td>
      </tr>
      <tr>
          <td>協作需求</td>
          <td>團隊共用、需要 PR review</td>
          <td>通常個人維護，PR review 是可選的</td>
      </tr>
  </tbody>
</table>
<p>這個平行不只是比喻。<a href="/blog/linux/dotfile/09-team-environment/" data-link-title="模組九：從個人到團隊" data-link-desc="個人 dotfile 管理的思想要延伸到團隊開發環境標準化時回來讀 — devcontainer、nix、商業環境配置管理">從個人到團隊</a>會教怎麼把 dotfile 的思想正式擴展到團隊環境——devcontainer 把「開發環境應該長什麼樣」寫成宣告式配置，讓新人 clone repo 就能拿到一致的開發環境，這正是 IaC 思想從組織 infra 往個人工作桌面延伸的具體產物。</p>
<h2 id="dotfile-是重建指令不是備份">Dotfile 是重建指令，不是備份</h2>
<p>這是最重要的心智模型區分。Dotfile repo 的目標不是「把舊電腦的所有檔案搬到新電腦」（那是備份工具的工作），而是「一份能在空白機器上重建工作環境的指令集」。</p>
<p>這個思維跟 Docker 的哲學一致：Docker image 透過 Dockerfile「描述如何重建」環境，而不是「對一台跑著的伺服器拍快照」。Dotfile repo 也是——它記錄的是「你的環境應該長什麼樣」的宣告，不是「你的機器上現在有什麼」的快照。</p>
<p>這個區分決定了 repo 裡該放什麼：</p>
<ul>
<li>放進去的：<strong>宣告式的配置檔</strong>（shell config、editor config、WM config）、<strong>套件清單</strong>（Brewfile、pacman list）、<strong>安裝腳本</strong>（<code>install.sh</code>，用來在新機器上自動化部署流程）。</li>
<li>不放的：<strong>暫存狀態</strong>（shell history、undo file、session file）、<strong>generated 產物</strong>（plugin 的 compiled cache）、<strong>大型二進位檔</strong>（字型檔案可以用套件管理器裝，不用放 repo）。</li>
</ul>
<p>維持「重建指令」的純度，repo 才能保持輕量、diff 可讀、跨機器部署不會帶進不必要的狀態。</p>
]]></content:encoded></item><item><title>環境建置的操作順序</title><link>https://tarrragon.github.io/blog/linux/dotfile/00-dotfile-mindset/setup-order-guide/</link><pubDate>Tue, 30 Jun 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/linux/dotfile/00-dotfile-mindset/setup-order-guide/</guid><description>&lt;p>Dotfile 教學模組按主題組織（shell、終端機、視窗管理），適合理解各層概念。但第一次建環境時需要的是另一種順序——&lt;strong>按依賴關係排列的操作清單&lt;/strong>，因為有些步驟是後續步驟的前提。&lt;/p>
&lt;p>SSH key 是典型例子：管理工具和 shell 配置的知識在模組一和模組二，但實際操作時 SSH key 比這兩者都早——因為 &lt;code>git clone git@github.com:...&lt;/code> 本身就需要 SSH key。如果照模組順序走，到模組二才發現 dotfile repo clone 不下來。&lt;/p>
&lt;p>這篇是路線圖，告訴你每一步做什麼、為什麼這個順序、以及去哪個模組看具體操作。&lt;/p>
&lt;h2 id="階段一基礎設施後續所有步驟的前提">階段一：基礎設施（後續所有步驟的前提）&lt;/h2>
&lt;p>這些步驟在任何配置之前完成，因為它們是 Git、遠端存取、dotfile clone 的前提。&lt;/p>
&lt;h3 id="1-安裝作業系統--建立使用者帳號">1. 安裝作業系統 + 建立使用者帳號&lt;/h3>
&lt;p>macOS：開箱即用。Linux：選發行版（Arch 如果要用 Hyprland）、完成安裝、建立非 root 使用者。安裝程式每個選項該怎麼判讀、裝完最小系統缺哪些必要工具（連 &lt;code>sudo&lt;/code> 都可能沒有），見 &lt;a href="https://tarrragon.github.io/blog/linux/install/install-option-decisions/" data-link-title="Linux 安裝選項判讀" data-link-desc="在 Linux 安裝程式面對 locale、網路、磁碟分割、檔案系統、bootloader 等選項、需要判斷依據而非靠預設值硬選時回來讀">Linux 安裝選項判讀&lt;/a> 與 &lt;a href="https://tarrragon.github.io/blog/linux/install/minimal-install-verify/" data-link-title="最小安裝後的工具驗證與補足" data-link-desc="最小化安裝的 Linux 裝完發現連 sudo 或 which 都沒有、bootstrap 腳本第一行就炸、需要先確認系統缺哪些必要工具再補時回來讀">最小安裝後的工具驗證與補足&lt;/a>——這一步是整個系列展開最深、卻最常被一句帶過的地基。&lt;/p>
&lt;h3 id="2-生成-ssh-key-pair">2. 生成 SSH key pair&lt;/h3>





&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="ln">1&lt;/span>&lt;span class="cl">ssh-keygen -t ed25519 -C &lt;span class="s2">&amp;#34;your-email@example.com&amp;#34;&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>為什麼這麼早做：&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Git 操作&lt;/strong>：GitHub / GitLab 的 SSH 認證需要 public key。dotfile repo 通常用 SSH URL（&lt;code>git@github.com:...&lt;/code>），clone 前要先把 key 部署到 GitHub。用 HTTPS URL 可以繞過 SSH key，但長期來看 SSH key 是更省事的認證方式。還沒有 key、或想用 HTTPS / PAT 把 dotfile 弄進一台新機器的幾種路徑，見 &lt;a href="https://tarrragon.github.io/blog/linux/install/ssh-keyless-bootstrap/" data-link-title="外部連入、SSH key 與無 key 的 bootstrap 路徑" data-link-desc="要從本機終端機操作新裝好的 Linux 機器、設 SSH key 免密碼、或還沒有 key 就想把 dotfile 弄進機器跑 install.sh 時回來讀">外部連入、SSH key 與無 key 的 bootstrap 路徑&lt;/a>。&lt;/li>
&lt;li>&lt;strong>遠端救援&lt;/strong>：&lt;a href="https://tarrragon.github.io/blog/linux/dotfile/07-desktop-maintenance/" data-link-title="模組七：桌面環境維護與故障排除" data-link-desc="桌面凍結、compositor 掛了、或某個工具不回應時回來讀 — Linux 桌面的故障隔離模型、常見故障場景的恢復操作、日誌判讀與診斷工具">模組七&lt;/a>的場景三（GPU hang）依賴 SSH 作為桌面凍結時的救生通道。key 提前設好，出問題時才有路可走。&lt;/li>
&lt;li>&lt;strong>跨機器操作&lt;/strong>：筆電連桌機、桌機連 VM、VS Code Remote SSH——都靠這把 key。&lt;/li>
&lt;/ul>
&lt;h3 id="3-部署-public-key">3. 部署 public key&lt;/h3>
&lt;p>把 &lt;code>~/.ssh/id_ed25519.pub&lt;/code> 加到需要的服務：&lt;/p>





&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="ln">1&lt;/span>&lt;span class="cl">&lt;span class="c1"># 加到 GitHub&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">2&lt;/span>&lt;span class="cl">cat ~/.ssh/id_ed25519.pub
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">3&lt;/span>&lt;span class="cl">&lt;span class="c1"># 複製輸出，貼到 GitHub → Settings → SSH and GPG keys → New SSH key&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">4&lt;/span>&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">5&lt;/span>&lt;span class="cl">&lt;span class="c1"># 加到另一台機器（可選，用於跨機器 SSH）&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">6&lt;/span>&lt;span class="cl">ssh-copy-id user@target-machine&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="4-package-manager--git">4. Package manager + Git&lt;/h3>
&lt;p>macOS：先裝 Homebrew（macOS 的套件管理器，後續安裝 stow、tmux 等工具都靠它），再裝 Git：&lt;/p>





&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="ln">1&lt;/span>&lt;span class="cl">&lt;span class="c1"># 安裝 Homebrew&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">2&lt;/span>&lt;span class="cl">/bin/bash -c &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">3&lt;/span>&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">4&lt;/span>&lt;span class="cl">&lt;span class="c1"># 安裝 Git（或用 xcode-select --install，會一併裝 Apple 的 Git）&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">5&lt;/span>&lt;span class="cl">brew install git&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Arch：&lt;code>pacman&lt;/code> 隨 OS 安裝已可用，直接裝 Git：&lt;code>pacman -S git&lt;/code>。&lt;/p></description><content:encoded><![CDATA[<p>Dotfile 教學模組按主題組織（shell、終端機、視窗管理），適合理解各層概念。但第一次建環境時需要的是另一種順序——<strong>按依賴關係排列的操作清單</strong>，因為有些步驟是後續步驟的前提。</p>
<p>SSH key 是典型例子：管理工具和 shell 配置的知識在模組一和模組二，但實際操作時 SSH key 比這兩者都早——因為 <code>git clone git@github.com:...</code> 本身就需要 SSH key。如果照模組順序走，到模組二才發現 dotfile repo clone 不下來。</p>
<p>這篇是路線圖，告訴你每一步做什麼、為什麼這個順序、以及去哪個模組看具體操作。</p>
<h2 id="階段一基礎設施後續所有步驟的前提">階段一：基礎設施（後續所有步驟的前提）</h2>
<p>這些步驟在任何配置之前完成，因為它們是 Git、遠端存取、dotfile clone 的前提。</p>
<h3 id="1-安裝作業系統--建立使用者帳號">1. 安裝作業系統 + 建立使用者帳號</h3>
<p>macOS：開箱即用。Linux：選發行版（Arch 如果要用 Hyprland）、完成安裝、建立非 root 使用者。安裝程式每個選項該怎麼判讀、裝完最小系統缺哪些必要工具（連 <code>sudo</code> 都可能沒有），見 <a href="/blog/linux/install/install-option-decisions/" data-link-title="Linux 安裝選項判讀" data-link-desc="在 Linux 安裝程式面對 locale、網路、磁碟分割、檔案系統、bootloader 等選項、需要判斷依據而非靠預設值硬選時回來讀">Linux 安裝選項判讀</a> 與 <a href="/blog/linux/install/minimal-install-verify/" data-link-title="最小安裝後的工具驗證與補足" data-link-desc="最小化安裝的 Linux 裝完發現連 sudo 或 which 都沒有、bootstrap 腳本第一行就炸、需要先確認系統缺哪些必要工具再補時回來讀">最小安裝後的工具驗證與補足</a>——這一步是整個系列展開最深、卻最常被一句帶過的地基。</p>
<h3 id="2-生成-ssh-key-pair">2. 生成 SSH key pair</h3>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl">ssh-keygen -t ed25519 -C <span class="s2">&#34;your-email@example.com&#34;</span></span></span></code></pre></div><p>為什麼這麼早做：</p>
<ul>
<li><strong>Git 操作</strong>：GitHub / GitLab 的 SSH 認證需要 public key。dotfile repo 通常用 SSH URL（<code>git@github.com:...</code>），clone 前要先把 key 部署到 GitHub。用 HTTPS URL 可以繞過 SSH key，但長期來看 SSH key 是更省事的認證方式。還沒有 key、或想用 HTTPS / PAT 把 dotfile 弄進一台新機器的幾種路徑，見 <a href="/blog/linux/install/ssh-keyless-bootstrap/" data-link-title="外部連入、SSH key 與無 key 的 bootstrap 路徑" data-link-desc="要從本機終端機操作新裝好的 Linux 機器、設 SSH key 免密碼、或還沒有 key 就想把 dotfile 弄進機器跑 install.sh 時回來讀">外部連入、SSH key 與無 key 的 bootstrap 路徑</a>。</li>
<li><strong>遠端救援</strong>：<a href="/blog/linux/dotfile/07-desktop-maintenance/" data-link-title="模組七：桌面環境維護與故障排除" data-link-desc="桌面凍結、compositor 掛了、或某個工具不回應時回來讀 — Linux 桌面的故障隔離模型、常見故障場景的恢復操作、日誌判讀與診斷工具">模組七</a>的場景三（GPU hang）依賴 SSH 作為桌面凍結時的救生通道。key 提前設好，出問題時才有路可走。</li>
<li><strong>跨機器操作</strong>：筆電連桌機、桌機連 VM、VS Code Remote SSH——都靠這把 key。</li>
</ul>
<h3 id="3-部署-public-key">3. 部署 public key</h3>
<p>把 <code>~/.ssh/id_ed25519.pub</code> 加到需要的服務：</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl"><span class="c1"># 加到 GitHub</span>
</span></span><span class="line"><span class="ln">2</span><span class="cl">cat ~/.ssh/id_ed25519.pub
</span></span><span class="line"><span class="ln">3</span><span class="cl"><span class="c1"># 複製輸出，貼到 GitHub → Settings → SSH and GPG keys → New SSH key</span>
</span></span><span class="line"><span class="ln">4</span><span class="cl">
</span></span><span class="line"><span class="ln">5</span><span class="cl"><span class="c1"># 加到另一台機器（可選，用於跨機器 SSH）</span>
</span></span><span class="line"><span class="ln">6</span><span class="cl">ssh-copy-id user@target-machine</span></span></code></pre></div><h3 id="4-package-manager--git">4. Package manager + Git</h3>
<p>macOS：先裝 Homebrew（macOS 的套件管理器，後續安裝 stow、tmux 等工具都靠它），再裝 Git：</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl"><span class="c1"># 安裝 Homebrew</span>
</span></span><span class="line"><span class="ln">2</span><span class="cl">/bin/bash -c <span class="s2">&#34;</span><span class="k">$(</span>curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh<span class="k">)</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="ln">3</span><span class="cl">
</span></span><span class="line"><span class="ln">4</span><span class="cl"><span class="c1"># 安裝 Git（或用 xcode-select --install，會一併裝 Apple 的 Git）</span>
</span></span><span class="line"><span class="ln">5</span><span class="cl">brew install git</span></span></code></pre></div><p>Arch：<code>pacman</code> 隨 OS 安裝已可用，直接裝 Git：<code>pacman -S git</code>。</p>
<h3 id="5-clone-dotfile-repo">5. Clone dotfile repo</h3>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl">git clone git@github.com:yourname/dotfiles.git ~/dotfiles</span></span></code></pre></div><p>如果是第一次建 dotfile repo（還沒有 repo），先建一個空的再開始往裡面加配置。具體做法見<a href="/blog/linux/dotfile/01-dotfile-management/" data-link-title="模組一：管理工具與目錄結構" data-link-desc="要把散落在家目錄的配置檔集中版控時，選 bare repo、stow 還是 chezmoi、目錄該怎麼組織">模組一：管理工具與目錄結構</a>。</p>
<h2 id="階段二shell-與終端機日常操作的基礎">階段二：Shell 與終端機（日常操作的基礎）</h2>
<p>Shell 是所有操作的介面，終端機是 shell 的容器。這兩層配置好，後續的安裝、設定、除錯效率會高很多。</p>
<h3 id="6-安裝管理工具stow--chezmoi">6. 安裝管理工具（stow / chezmoi）</h3>
<p>把 dotfile repo 裡的配置 symlink 到正確位置。具體選型和操作見<a href="/blog/linux/dotfile/01-dotfile-management/" data-link-title="模組一：管理工具與目錄結構" data-link-desc="要把散落在家目錄的配置檔集中版控時，選 bare repo、stow 還是 chezmoi、目錄該怎麼組織">模組一</a>。</p>
<h3 id="7-shell-配置zshrc--bashrc">7. Shell 配置（.zshrc / .bashrc）</h3>
<p>模組化拆分、PATH 設定、alias、prompt。做完這一步，終端機操作才順手。見<a href="/blog/linux/dotfile/02-shell-config/" data-link-title="模組二：Shell 配置" data-link-desc="shell 配置檔長成一坨不敢動時回來讀 — .zshrc/.bashrc 的結構化拆分、alias/function/PATH 的模組化設計">模組二：Shell 配置</a>。</p>
<h3 id="8-終端機--編輯器">8. 終端機 + 編輯器</h3>
<p>Terminal emulator 選型、tmux/zellij、neovim 基礎配置。見<a href="/blog/linux/dotfile/03-terminal-ecosystem/" data-link-title="模組三：終端機與編輯器" data-link-desc="終端機相關工具的配置檔散落在不同位置、不確定哪些該進 dotfile repo 時回來讀">模組三：終端機與編輯器</a>。</p>
<p>macOS 用戶到階段二完成後就有一個完整的工作環境。下一步依序讀<a href="/blog/linux/dotfile/01-dotfile-management/" data-link-title="模組一：管理工具與目錄結構" data-link-desc="要把散落在家目錄的配置檔集中版控時，選 bare repo、stow 還是 chezmoi、目錄該怎麼組織">模組一</a>（管理工具選型）、<a href="/blog/linux/dotfile/02-shell-config/" data-link-title="模組二：Shell 配置" data-link-desc="shell 配置檔長成一坨不敢動時回來讀 — .zshrc/.bashrc 的結構化拆分、alias/function/PATH 的模組化設計">模組二</a>（shell 配置）、<a href="/blog/linux/dotfile/03-terminal-ecosystem/" data-link-title="模組三：終端機與編輯器" data-link-desc="終端機相關工具的配置檔散落在不同位置、不確定哪些該進 dotfile repo 時回來讀">模組三</a>（終端機），然後跳到階段四的 bootstrap script。階段三是 Linux 桌面環境的設定，macOS 用戶跳過。</p>
<h2 id="階段三桌面環境linux-限定">階段三：桌面環境（Linux 限定）</h2>
<p>macOS 用戶到階段二就有一個完整的工作環境了。以下步驟是 Linux 桌面環境的設定，macOS 用戶可以跳到階段四。</p>
<h3 id="9-視窗管理器">9. 視窗管理器</h3>
<p>平鋪式 vs 浮動式的選型，Hyprland 安裝和核心配置。見<a href="/blog/linux/dotfile/04-window-management/" data-link-title="模組四：視窗管理與平鋪式工作流" data-link-desc="同時開多個視窗時的排列策略 — 手動貼齊跟自動平鋪的差距在哪、macOS 和 Linux 各有哪些工具、多螢幕怎麼處理、什麼情境值得從浮動切換到平鋪">模組四</a>和<a href="/blog/linux/dotfile/05-hyprland-config/" data-link-title="模組五：Hyprland 配置" data-link-desc="要在 Linux 上設定 Hyprland 平鋪式桌面時回來讀">模組五</a>。</p>
<h3 id="10-桌面配套工具--rice">10. 桌面配套工具 + Rice</h3>
<p>waybar、wofi、mako、配色系統。見<a href="/blog/linux/dotfile/06-rice-design/" data-link-title="模組六：桌面 Rice 設計" data-link-desc="Hyprland 桌面從能用到好看好用 — 狀態列、啟動器、通知、鎖屏、配色系統的設計與配置">模組六：桌面 Rice 設計</a>。</p>
<h3 id="11-啟用-ssh-server--預防措施">11. 啟用 SSH server + 預防措施</h3>
<p>桌面環境可用之後，設定遠端救援通道和預防性配置：</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln"> 1</span><span class="cl"><span class="c1"># SSH server（出問題時可以從另一台機器救援）</span>
</span></span><span class="line"><span class="ln"> 2</span><span class="cl">sudo systemctl <span class="nb">enable</span> sshd
</span></span><span class="line"><span class="ln"> 3</span><span class="cl">sudo systemctl start sshd
</span></span><span class="line"><span class="ln"> 4</span><span class="cl">
</span></span><span class="line"><span class="ln"> 5</span><span class="cl"><span class="c1"># 停用密碼登入（確保 SSH key 已設好）</span>
</span></span><span class="line"><span class="ln"> 6</span><span class="cl"><span class="c1"># 編輯 /etc/ssh/sshd_config：PasswordAuthentication no</span>
</span></span><span class="line"><span class="ln"> 7</span><span class="cl">
</span></span><span class="line"><span class="ln"> 8</span><span class="cl"><span class="c1"># swap（OOM 緩衝）</span>
</span></span><span class="line"><span class="ln"> 9</span><span class="cl">sudo fallocate -l 4G /swapfile
</span></span><span class="line"><span class="ln">10</span><span class="cl">sudo chmod <span class="m">600</span> /swapfile <span class="o">&amp;&amp;</span> sudo mkswap /swapfile <span class="o">&amp;&amp;</span> sudo swapon /swapfile
</span></span><span class="line"><span class="ln">11</span><span class="cl">
</span></span><span class="line"><span class="ln">12</span><span class="cl"><span class="c1"># systemd-oomd</span>
</span></span><span class="line"><span class="ln">13</span><span class="cl">sudo systemctl <span class="nb">enable</span> systemd-oomd</span></span></code></pre></div><p>為什麼放在桌面設定之後：SSH server 和 swap 是預防措施，桌面能用了才有東西要保護。但 SSH key pair（階段一步驟 2-3）要提前做——key pair 是認證基礎設施，server 只是把門打開。</p>
<p>詳細的故障場景和預防措施見<a href="/blog/linux/dotfile/07-desktop-maintenance/" data-link-title="模組七：桌面環境維護與故障排除" data-link-desc="桌面凍結、compositor 掛了、或某個工具不回應時回來讀 — Linux 桌面的故障隔離模型、常見故障場景的恢復操作、日誌判讀與診斷工具">模組七：桌面環境維護與故障排除</a>。</p>
<h2 id="階段四同步與可攜性">階段四：同步與可攜性</h2>
<p>環境建好之後，確保這份配置能搬到下一台機器。</p>
<h3 id="12-bootstrap-script">12. Bootstrap script</h3>
<p>把階段一到三的操作自動化成 script，下次換機器跑一次就好。見<a href="/blog/linux/dotfile/08-sync-bootstrap/" data-link-title="模組八：同步、Bootstrap 與環境重建" data-link-desc="換機器或重灌時怎麼還原工作環境 — bootstrap script 設計、套件清單管理、跨機器同步策略、secret 排除，以及 VM 快照和 dotfile 重建兩種思路的場景判讀">模組八：同步、Bootstrap 與環境重建</a>。</p>
<h3 id="13-secret-管理">13. Secret 管理</h3>
<p>哪些東西該進 repo、哪些要排除（SSH private key、API token、密碼）。同樣見<a href="/blog/linux/dotfile/08-sync-bootstrap/" data-link-title="模組八：同步、Bootstrap 與環境重建" data-link-desc="換機器或重灌時怎麼還原工作環境 — bootstrap script 設計、套件清單管理、跨機器同步策略、secret 排除，以及 VM 快照和 dotfile 重建兩種思路的場景判讀">模組八</a>。</p>
<h2 id="依賴關係速查">依賴關係速查</h2>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="ln"> 1</span><span class="cl">OS 安裝
</span></span><span class="line"><span class="ln"> 2</span><span class="cl">  └─ SSH key pair ← 後續所有 Git / SSH 操作的前提
</span></span><span class="line"><span class="ln"> 3</span><span class="cl">       └─ Git 安裝
</span></span><span class="line"><span class="ln"> 4</span><span class="cl">            └─ dotfile repo clone
</span></span><span class="line"><span class="ln"> 5</span><span class="cl">                 └─ 管理工具（stow link）
</span></span><span class="line"><span class="ln"> 6</span><span class="cl">                      ├─ Shell 配置
</span></span><span class="line"><span class="ln"> 7</span><span class="cl">                      ├─ 終端機 + 編輯器
</span></span><span class="line"><span class="ln"> 8</span><span class="cl">                      └─ 桌面環境（Linux，macOS 到此為止 → 直接跳階段四）
</span></span><span class="line"><span class="ln"> 9</span><span class="cl">                           └─ SSH server + 預防措施
</span></span><span class="line"><span class="ln">10</span><span class="cl">                                └─ Bootstrap script 自動化</span></span></code></pre></div><h2 id="可以亂序的步驟">可以亂序的步驟</h2>
<p>依賴圖裡<strong>同一層級的步驟</strong>可以調換順序。具體來說：</p>
<ul>
<li>Shell 配置、終端機配置、編輯器配置三者互不依賴，先做哪個都行</li>
<li>視窗管理器和桌面配套工具可以交替設定（先裝 Hyprland 再裝 waybar，或反過來）</li>
<li>swap 和 SSH server 互不依賴，先做哪個都行</li>
</ul>
<p>跨層級的依賴必須按順序：SSH key 是 clone repo 的前提，repo 是 stow link 的前提，stow link 是 shell 配置生效的前提。</p>
]]></content:encoded></item></channel></rss>