跳到主要内容

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
基础
brew install starship
使用 Homebrew 安装 starship(macOS)
基础
scoop install starship
使用 Scoop 安装 starship(Windows)
基础
starship init bash
为 Bash 初始化 starship(添加到 .bashrc)
基础
starship init zsh
为 Zsh 初始化 starship(添加到 .zshrc)
基础
starship init fish
为 Fish 初始化 starship
基础
starship init powershell
为 PowerShell 初始化 starship
基础
starship init elvish
为 Elvish 初始化 starship
中级
STARSHIP_CONFIG
自定义配置文件路径的环境变量
中级
STARSHIP_CACHE
自定义缓存目录的环境变量
中级

配置管理(6)

命令难度
starship config
查看当前 starship 配置
基础
starship config KEY VALUE
设置配置项(如 format, add_newline 等)
基础
~/.config/starship.toml
starship 默认配置文件路径(TOML 格式)
基础
starship config --help
显示 starship config 子命令帮助
基础
starship config palette
设置颜色调色板
中级
starship config format
自定义提示符格式(全部)
高级

模块配置(7)

命令难度
starship config character
配置提示符字符(如改用 ➜)
中级
starship config git_branch
配置 Git 分支模块
中级
starship config nodejs
配置 Node.js 版本显示
中级
starship config directory
配置目录显示格式
中级
starship config python
配置 Python 虚拟环境显示
中级
starship config docker
配置 Docker 上下文显示
中级
starship config kubernetes
配置 Kubernetes 上下文显示
中级

提示符定制(6)

命令难度
starship preset
列出所有可用预设主题
基础
starship preset PRESET_NAME -o ~/.config/starship.toml
应用预设主题到配置文件
基础
starship preset bracketed-segments
应用 bracketed-segments 预设(各段带括号)
基础
starship preset pastel-powerline
应用 pastel-powerline 预设(柔色风格)
基础
starship preset tokyo-night
应用 Tokyo Night 预设
基础
starship toggle
在提示符中切换模块的显示/隐藏
中级

高级用法(9)

命令难度
starship session
生成用于终端会话初始化的 Shell 代码
advanced
starship timings
分析各模块渲染耗时(性能诊断)
中级
starship explain
解释当前提示符各段的含义
中级
starship bug-report
生成 Bug 报告所需信息
基础
starship toml
将配置文件转换为标准 TOML 格式
advanced
starship --version
显示 starship 版本号
基础
starship completions
生成 Shell 自动补全脚本
advanced
starship module
渲染单个模块(用于调试)
高级
starship print-config
打印解析后的完整配置
中级

常见问题

本速查表数据整理自各工具官方文档。最后更新: 2026-07-20。