Skip to content

Commit d6232b7

Browse files
committed
feat(shell): 为 Bash 和 Zsh 添加 Starship 提示符初始化
在 shell/shared.d/ 片段系统中新增 zz-prompt.sh,为 Bash 和 Zsh 提供 Starship prompt 初始化。该脚本会检测 shell 类型并执行对应的 starship init 命令,若未安装 starship 则静默跳过。使用 zz- 前缀确保在环境变量设置完成后加载,避免依赖顺序问题。
1 parent 842290a commit d6232b7

6 files changed

Lines changed: 35 additions & 0 deletions

File tree

openspec/changes/add-starship-shell-init/.openspec.yaml renamed to openspec/changes/archive/2026-02-25-add-starship-shell-init/.openspec.yaml

File renamed without changes.

openspec/changes/add-starship-shell-init/design.md renamed to openspec/changes/archive/2026-02-25-add-starship-shell-init/design.md

File renamed without changes.

openspec/changes/add-starship-shell-init/proposal.md renamed to openspec/changes/archive/2026-02-25-add-starship-shell-init/proposal.md

File renamed without changes.

openspec/changes/add-starship-shell-init/specs/starship-shell-init/spec.md renamed to openspec/changes/archive/2026-02-25-add-starship-shell-init/specs/starship-shell-init/spec.md

File renamed without changes.

openspec/changes/add-starship-shell-init/tasks.md renamed to openspec/changes/archive/2026-02-25-add-starship-shell-init/tasks.md

File renamed without changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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` 等所有其他片段之后加载

0 commit comments

Comments
 (0)