File tree Expand file tree Collapse file tree
changes/archive/2026-02-25-add-starship-shell-init
specs/starship-shell-init
specs/starship-shell-init Expand file tree Collapse file tree File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ ### Requirement: Starship prompt 初始化
2+ ` shell/shared.d/zz-prompt.sh ` SHALL 为 Bash 和 Zsh 提供 Starship prompt 初始化。
3+
4+ #### Scenario: Zsh 会话加载 Starship
5+ - ** WHEN** 用户在已安装 starship 的系统上启动 Zsh 会话,且 ` ~/.bashrc.d/ ` 片段已部署
6+ - ** THEN** Starship prompt 正确显示,替代默认 Zsh prompt
7+
8+ #### Scenario: Bash 会话加载 Starship
9+ - ** WHEN** 用户在已安装 starship 的系统上启动 Bash 会话,且 ` ~/.bashrc.d/ ` 片段已部署
10+ - ** THEN** Starship prompt 正确显示,替代默认 Bash prompt
11+
12+ ### Requirement: Shell 类型自动检测
13+ 初始化脚本 SHALL 根据当前 shell 类型(` $ZSH_VERSION ` 或 ` $BASH_VERSION ` )自动选择正确的 ` starship init ` 参数。
14+
15+ #### Scenario: Zsh 环境检测
16+ - ** WHEN** 脚本在 Zsh 中被 source
17+ - ** THEN** 执行 ` eval "$(starship init zsh)" `
18+
19+ #### Scenario: Bash 环境检测
20+ - ** WHEN** 脚本在 Bash 中被 source
21+ - ** THEN** 执行 ` eval "$(starship init bash)" `
22+
23+ ### Requirement: 未安装时静默跳过
24+ 当 starship 未安装时,脚本 SHALL 静默退出,不输出任何错误或提示信息。
25+
26+ #### Scenario: Starship 未安装
27+ - ** WHEN** 系统未安装 starship(` command -v starship ` 失败)
28+ - ** THEN** 脚本静默退出,shell 使用默认 prompt,无错误输出
29+
30+ ### Requirement: 加载顺序保证
31+ 脚本文件名 SHALL 使用 ` zz- ` 前缀,确保在所有其他 ` shared.d/ ` 片段之后加载。
32+
33+ #### Scenario: 片段加载顺序
34+ - ** WHEN** ` ~/.bashrc.d/ ` 下的片段按字母序加载
35+ - ** THEN** ` zz-prompt.sh ` 在 ` aliases.sh ` 、` path.sh ` 、` proxy.sh ` 等所有其他片段之后加载
You can’t perform that action at this time.
0 commit comments