Starship 跨 Shell 极简提示符安装与使用指南【免费下载链接】starship☄️ The minimal, blazing-fast, and infinitely customizable prompt for any shell!项目地址: https://gitcode.com/GitHub_Trending/st/starshipStarship 是一款用 Rust 编写、面向“宇航员”的跨 Shell 提示符cross-shell prompt。它追求最小化、极速与无限可定制无论是 Bash、Zsh、Fish、PowerShell 还是 Nushell安装后都能立即获得同一套信息丰富且美观的提示界面。本指南以官方文档为骨架逐平台讲解 Starship 的安装方式、各 Shell 的初始化步骤并结合本仓库源码解释其“init prompt”的工作原理让读者在几分钟内完成从零安装到个性化配置的完整链路。本文依据仓库内荷兰语入门文档 docs/nl-NL/guide/README.md与各语言版 guide 内容等价整理编写该文档中出现的安装表格、初始化代码与注意事项已全部保留并作源码级补充。Starship 是什么核心特性一览Starship 的定位是一句话可以讲清楚的——最小化、极速、且几乎可无限定制的提示符但支撑它的特性远不止一句口号快Snel提示渲染开销被压到极低。项目本身以 Rust 编写整个提示的拼接逻辑由一个常驻的轻量二进制完成。可定制Aanpasbaar提示中的每个部件module都可以独立开关、改色、改符号。官方配置文档位于 docs/config/README.md。通用Universeel同一份二进制与同一套starship.toml配置在 Linux、macOS、Windows、BSD 以及 AndroidTermux上表现一致真正的“一次配置处处使用”。智能Intelligent只在需要时显示相关信息。例如当前目录是 Node.js 项目才显示 Node 版本位于 Git 仓库内才显示分支与状态。功能丰富Rijk aan functies内置数十个模块覆盖 Git、各类语言运行时、容器、云平台等。可以在 src/configs 与 src/modules 目录看到与之一一对应的配置与实现文件。易用Makkelijk安装脚本加一行 Shell 初始化即可全程几分钟。从源码结构看这一“单二进制多 Shell 适配”的设计正是通过 src/init 下各 Shell 的引导脚本与 src/main.rs 的 CLI 子命令协作实现的下文安装完成后会展开说明。安装前置准备 Nerd Font在安装 Starship 之前官方要求终端中已安装并启用了Nerd Font可从 Nerd Fonts 项目下载官方示例推荐 Firacode Nerd Font。原因是 Starship 默认提示符大量使用图标与特殊符号普通字体无法正确渲染这些字形会导致箭头、分支图标等显示为乱码或方框。如果暂时无法更换字体仍可继续使用 Starship——文档 docs/presets/no-nerd-font.md 与 docs/presets/no-empty-icons.md 提供了完全不依赖 Nerd Font、或去除空图标占位的预设方案。分平台安装 Starship仓库根目录的 install/install.sh 提供了 curl 一键脚本下文的 Linux / macOS 示例即引用它脚本内部会根据系统架构下载对应预编译二进制。以下按官方文档的结构逐平台列出全部安装途径。AndroidTermux仓库安装命令Termuxpkg install starshipBSD发行版仓库安装命令任意crates.iocargo install starship --lockedFreeBSDFreshPortspkg install starshipNetBSDpkgsrcpkgin install starship其中cargo install starship --locked需要系统已安装 Rust 工具链--locked会严格依照 Cargo.lock 锁定依赖版本保证可复现构建。Linux获取最新版本的首选方式是一键脚本curl -sS https://starship.rs/install.sh | sh仓库中同样提供可审计的安装脚本副本install/install.sh感兴趣的读者可直接阅读其逻辑。除此之外官方文档罗列了以下主流发行版的包管理器途径发行版仓库安装命令任意crates.iocargo install starship --locked任意conda-forgeconda install -c conda-forge starship任意Linuxbrewbrew install starshipAlpine Linux 3.13Alpine Linux Packagesapk add starshipArch LinuxArch Linux Extrapacman -S starshipCentOS 7Coprdnf copr enable atim/starshipdnf install starshipDebian 13Debian Mainapt install starshipFedora 40Coprdnf copr enable atim/starshipdnf install starshipGentooGentoo Packagesemerge app-shells/starshipManjaro—pacman -S starshipNixOSnixpkgsnix-env -iA nixpkgs.starshipopenSUSEOSSzypper in starshipUbuntu 25.04Ubuntu Universeapt install starshipVoid LinuxVoid Linux Packagesxbps-install -S starshipmacOScurl -sS https://starship.rs/install.sh | sh或使用下列包管理器仓库安装命令crates.iocargo install starship --lockedconda-forgeconda install -c conda-forge starshipHomebrewbrew install starshipMacPortsport install starship对需要签名分发、打包分发安装包的场景仓库还提供了 macOS 的 pkg 构建脚本install/macos_packages与 Windows 的 WiX 安装程序定义install/windows/main.wxs可作参考。WindowsWindows 用户可从 Releases 区下载 MSI 安装包也可通过包管理器安装仓库安装命令crates.iocargo install starship --lockedChocolateychoco install starshipconda-forgeconda install -c conda-forge starshipScoopscoop install starshipwingetwinget install --id Starship.Starship初始化 Shell让提示符接管终端安装好二进制后还需在各 Shell 的启动文件中写入一行初始化代码。这一行会执行starship init shell把 Starship 的引导逻辑注入当前 Shell。从源码角度理解starship init bash、starship init zsh等命令对应 src/main.rs 中定义的Init子命令其输出的是“用于执行 starship 的 Shell 函数”而 src/init 目录下的starship.bash、starship.zsh、starship.fish、starship.ps1、starship.elv、starship.luaCmd/Clink、starship.nu、starship.ion、starship.tcsh、starship.xsh正是各 Shell 的真实引导脚本源文件初始化时会渲染为对应终端内容。各 Shell 的官方配置方法如下请按需选用并严格注意末尾的版本/路径备注。Bash在~/.bashrc末尾追加eval $(starship init bash)以 Bash 引导脚本src/init/starship.bash为例其内部通过PROMPT_COMMAND与DEBUGtrap 收集命令执行计时信息并在每次绘制提示符前调用starship prompt --status... --cmd-duration...计算出包含退出码、执行时长等信息的完整提示符字符串再写入PS1。CmdWindows需要配合 Clinkv1.2.30使用。在%LocalAppData%\clink\starship.lua中创建文件并写入load(io.popen(starship init cmd):read(*a))()Elvish在~/.config/elvish/rc.elvWindows 为%AppData%\elvish\rc.elv末尾追加eval (starship init elvish)注意仅支持 Elvish v0.18对于 v0.21.0 之前的版本配置文件可能位于~/.elvish/rc.elv。Fish在~/.config/fish/config.fish末尾追加starship init fish | sourceIon在~/.config/ion/initrc末尾追加eval $(starship init ion)Nushell在 Nushell 配置中追加以下内容可用$nu.config-path找到该配置文件mkdir ($nu.data-dir | path join vendor/autoload) starship init nu | save -f ($nu.data-dir | path join vendor/autoload/starship.nu)注意仅支持 Nushell v0.96。PowerShell在 PowerShell 配置可用$PROFILE找到该文件末尾追加Invoke-Expression (starship init powershell)Tcsh在~/.tcshrc末尾追加eval starship init tcshXonsh在~/.xonshrc末尾追加execx($(starship init xonsh))Zsh在~/.zshrc末尾追加eval $(starship init zsh)验证与继续个性化完成上述两步后新开一个 Shell 实例就能看到全新的提示符。若默认外观已满足需求直接使用即可。若想进一步定制官方文档给出了两条主线Configuration配置阅读 docs/config/README.md学习模块开关、格式字符串、颜色与符号的定制方法。所有配置都集中在~/.config/starship.toml这一个 TOML 文件中并通过可选的STARSHIP_CONFIG环境变量覆盖默认路径。Presets预设参考 docs/presets/README.md直接套用社区预置主题如 tokyo-night、gruvbox-rainbow、catppuccin-powerline 等对应文件见 docs/presets 目录下的各 markdown 与示例。若想快速把某个预设写入配置文件可使用starship preset name子命令输出预设内容。仓库还提供了几个实用的命令行小工具同样定义于 src/main.rs便于日常调试starship module name单独打印某个模块的渲染结果排查单个模块显示问题时非常有用starship config key value直接对配置项进行读取/编辑实现见 src/configure.rsstarship bug-report生成一份预填好的 Issue 报告包含你的配置与系统信息便于向项目反馈问题。另外需要注意主分支名称已从master更名为main。若你本地已有克隆仓库官方建议执行以下命令完成同步git branch -m master main git fetch origin git branch -u origin/main main git remote set-head origin -a结语本指南完整复现了 Starship 官方入门流程的三大步骤——准备 Nerd Font、按平台安装二进制、按 Shell 写入初始化行——并揭示了其“Rust 二进制 各 Shell 引导脚本”的实现骨架。文档中每个 Shell 的初始化片段都对应着 src/init 下的一份真实引导脚本这份“一份配置、处处一致”的体验正是 Starship 作为跨 Shell 提示符的核心价值所在。完成安装后从 docs/config/README.md 出发即可开始打造真正属于自己的提示符。【免费下载链接】starship☄️ The minimal, blazing-fast, and infinitely customizable prompt for any shell!项目地址: https://gitcode.com/GitHub_Trending/st/starship创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考