starship 速查表
starship 是 Rust 编写的跨 Shell 提示符工具(58K⭐),速度快、可定制性强。支持 Bash、Zsh、Fish、PowerShell、Elvish 等主流 Shell,通过 TOML 配置文件实现模块化主题控制。
更新: 2026-07-20·38 条命令
快速开始
``bash
starship init bash # 为 Bash 初始化(添加到 .bashrc)
starship init zsh # 为 Zsh 初始化(添加到 .zshrc)
starship init fish # 为 Fish 初始化
`预设主题
`bash
starship preset --list # 列出所有预设
starship preset tokyo-night -o ~/.config/starship.toml # 应用 Tokyo Night
starship preset nerd-font-symbols -o ~/.config/starship.toml # Nerd Font 符号
`配置命令
`bash
starship config # 查看当前配置
starship config add_newline false # 禁用在提示符前换行
starship config character.style 'bold green' # 设置字符样式
`诊断工具
`bash
starship timings # 检查模块渲染耗时
starship explain # 解释提示符各段的含义
starship bug-report # 生成 Bug 报告信息
starship print-config # 显示解析后的完整配置
``
安装配置(10)
| 命令 | 难度 | ||
|---|---|---|---|
curl -sS https://starship.rs/install.sh | sh使用官方安装脚本安装 starship | 基础 | curl -sS https://starship.rs/install.sh | sh | |
brew install starship使用 Homebrew 安装 starship(macOS) | 基础 | brew install starship | |
scoop install starship使用 Scoop 安装 starship(Windows) | 基础 | scoop install starship | |
starship init bash为 Bash 初始化 starship(添加到 .bashrc) | 基础 | eval "$(starship init bash)" | |
starship init zsh为 Zsh 初始化 starship(添加到 .zshrc) | 基础 | eval "$(starship init zsh)" | |
starship init fish为 Fish 初始化 starship | 基础 | starship init fish | source | |
starship init powershell为 PowerShell 初始化 starship | 基础 | Invoke-Expression (&starship init powershell) | |
starship init elvish为 Elvish 初始化 starship | 中级 | eval (starship init elvish) | |
STARSHIP_CONFIG自定义配置文件路径的环境变量 | 中级 | export STARSHIP_CONFIG=~/.config/starship/custom.toml | |
STARSHIP_CACHE自定义缓存目录的环境变量 | 中级 | export STARSHIP_CACHE=~/.cache/starship-custom |
配置管理(6)
| 命令 | 难度 | ||
|---|---|---|---|
starship config查看当前 starship 配置 | 基础 | starship config | |
starship config KEY VALUE设置配置项(如 format, add_newline 等) | 基础 | starship config add_newline false | |
~/.config/starship.tomlstarship 默认配置文件路径(TOML 格式) | 基础 | vim ~/.config/starship.toml | |
starship config --help显示 starship config 子命令帮助 | 基础 | starship config --help | |
starship config palette设置颜色调色板 | 中级 | starship config palette catppuccin_mocha | |
starship config format自定义提示符格式(全部) | 高级 | starship config format '$all'
# Or custom: starship config format '[$username](bold blue) at [$hostname](red) in [$directory](green) '
'$git_branch$character' |
模块配置(7)
| 命令 | 难度 | ||
|---|---|---|---|
starship config character配置提示符字符(如改用 ➜) | 中级 | starship config character.style 'bold green'
starship config character.success_symbol '[➜](bold green)' | |
starship config git_branch配置 Git 分支模块 | 中级 | starship config git_branch.format '[$branch](bold purple)'
starship config git_branch.only_attached false | |
starship config nodejs配置 Node.js 版本显示 | 中级 | starship config nodejs.format 'via [⬢ $version](bold green)'
starship config nodejs.disabled false | |
starship config directory配置目录显示格式 | 中级 | starship config directory.truncation_length 3
starship config directory.truncate_to_repo false | |
starship config python配置 Python 虚拟环境显示 | 中级 | starship config python.format 'via [🐍 $version](bold yellow)'
starship config python.disabled false | |
starship config docker配置 Docker 上下文显示 | 中级 | starship config docker.format 'via [🐳 $context](bold blue)'
starship config docker.disabled false | |
starship config kubernetes配置 Kubernetes 上下文显示 | 中级 | starship config kubernetes.format '[$context](bold purple) in [$namespace](bold cyan)'
starship config kubernetes.disabled false |
提示符定制(6)
| 命令 | 难度 | ||
|---|---|---|---|
starship preset列出所有可用预设主题 | 基础 | starship preset --list | |
starship preset PRESET_NAME -o ~/.config/starship.toml应用预设主题到配置文件 | 基础 | starship preset nerd-font-symbols -o ~/.config/starship.toml | |
starship preset bracketed-segments应用 bracketed-segments 预设(各段带括号) | 基础 | starship preset bracketed-segments -o ~/.config/starship.toml | |
starship preset pastel-powerline应用 pastel-powerline 预设(柔色风格) | 基础 | starship preset pastel-powerline -o ~/.config/starship.toml | |
starship preset tokyo-night应用 Tokyo Night 预设 | 基础 | starship preset tokyo-night -o ~/.config/starship.toml | |
starship toggle在提示符中切换模块的显示/隐藏 | 中级 | starship toggle rust |
高级用法(9)
| 命令 | 难度 | ||
|---|---|---|---|
starship session生成用于终端会话初始化的 Shell 代码 | advanced | starship session --help | |
starship timings分析各模块渲染耗时(性能诊断) | 中级 | starship timings | |
starship explain解释当前提示符各段的含义 | 中级 | starship explain | |
starship bug-report生成 Bug 报告所需信息 | 基础 | starship bug-report | |
starship toml将配置文件转换为标准 TOML 格式 | advanced | starship toml < ~/.config/starship.toml | |
starship --version显示 starship 版本号 | 基础 | starship --version | |
starship completions生成 Shell 自动补全脚本 | advanced | starship completions bash > /usr/share/bash-completion/completions/starship | |
starship module渲染单个模块(用于调试) | 高级 | starship module git_branch | |
starship print-config打印解析后的完整配置 | 中级 | starship print-config |
常见问题
本速查表数据整理自各工具官方文档。最后更新: 2026-07-20。