ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

Starship Jetpack Preset 全解析:用终端原生配色打造伪极简双栏提示符

Starship Jetpack Preset 全解析:用终端原生配色打造伪极简双栏提示符 Starship Jetpack Preset 全解析用终端原生配色打造伪极简双栏提示符【免费下载链接】starship☄️ The minimal, blazing-fast, and infinitely customizable prompt for any shell!项目地址: https://gitcode.com/GitHub_Trending/st/starshipJetpack 是 Starship 社区预设集合中的一款「伪极简pseudo-minimalist」主题灵感来自 geometry 与 spaceship 两款知名 zsh 提示符方案。本文以官方预设说明及随附的 jetpack.toml 为骨架逐项讲解它的设计理念、启用方法、配置结构与源码实现原理读完即可安装使用并能在其基础上按需定制属于你自己的双栏提示符。核心特征一句话概括Jetpack复用终端的配色方案颜色全部取自基础 ANSI 色名把 Git、语言版本、云环境等大量信息移交到右侧提示符right prompt主提示行只保留最精简的动态要素从而实现视觉克制、信息不减的「伪极简」。设计理念什么是“伪极简主义”Jetpack 所属的预设集由社区提交并收录在 docs/presets/README.md 中每条预设均以一张实际截图 完整 TOML 配置文件的形式对外发布。Jetpack 的设计参考了两个经典 zsh 主题geometry以极简著称把大量信息藏进右侧或按需显示spaceship以「符号 语义段」的方式组织提示符信息。Jetpack 融合两者主提示行format保持短小仅保留 shell 环境、任务、用户名、命令耗时与 prompt 字符右侧right_format则几乎收容了全部上下文信息——工作目录、Git 状态、语言运行时版本、容器与云环境、电池电量等。由于右侧信息默认在输入换行前不会影响视觉主体因此从观感上是「极简」的但信息量并不打折这正是「伪极简」的由来。与纯极简配置不同的是Jetpack 的每条配置都通过基础 ANSI 颜色词如bright-yellow、purple、blue指定样式而非硬编码十六进制色值。这意味着预设不绑定固定调色板而会跟随你终端主题的 16 色方案自动换肤——官方文档因此专门注明Jetpack 使用终端的配色方案。前置条件要完整启用 Jetpack 的两栏布局需要满足两个条件1. 支持右侧提示符right prompt的 shellJetpack 把绝大多数模块放在right_format中而右侧提示行依赖 shell 自身的渲染通道。从 src/init 下的初始化脚本可以看到 Starship 为不同 shell 分别挂接右提示的实现zsh / fish通过各自的右提示钩子输出--right内容如 starship.fish 中的fish_right_promptbash在启用ble.sh增强时通过bleopt prompt_rps1渲染见 starship.bashelvish通过edit:rprompt呈现见 starship.elv。因此请确认你的 shell 具备右提示能力zsh、fish 是常见首选若 shell 不支持右提示Jetpack 右侧的大量模块将无法显示只保留主提示行效果会大打折扣。2. 推荐使用 JetBrains Mono 字体Jetpack 的符号体系◎、▴、⌂、◈等依赖等宽字体中的细线/几何字符排版。官方建议使用JetBrains Mono以保证▸▹、⎪…⎥这类边框与箭头符号的对齐效果。普通等宽字体虽可运行但观感可能参差。安装与启用Jetpack 与其他预设一样通过 Starship 内置的preset子命令安装。在已安装并初始化 Starship 的前提下执行starship preset jetpack -o ~/.config/starship.toml该命令会把内置的 jetpack 配置写入~/.config/starship.toml随后重开 shell 或执行exec $SHELL即可生效。如果只想把配置打印到标准输出查看去掉-o参数即可starship preset jetpack从 src/main.rs 的 CLI 定义可以看出preset子命令还支持以下能力-o, --output FILE把预设内容写入指定文件-f, --force当输出文件已存在时强制覆盖该选项依赖--output-l, --list列出所有可用预设名称。对应的实现位于 src/print.rs预设内容读取自编译期嵌入的 TOML写文件走原子写入write_file_atomic从而避免写一半留下损坏配置而-l列表则直接枚举全部内置预设。仓库自带的单元测试如 src/print.rs验证了「输出到文件的内容与docs/public/presets/toml/…中源码完全一致」这一约束。手动回退方案是直接下载 jetpack.toml 覆盖到你的配置路径Linux 下一般为~/.config/starship.tomlmacOS 为~/.config/starship.toml之后执行starship config可校验配置是否可被正确解析。配置文件逐段精讲jetpack.toml 首行声明了 schema 版本号配置主体可以分成三块全局参数与主提示行format、右侧提示行right_format、以及逐模块的定制段落。下面按顺序解读核心片段。全局参数与主提示行左侧add_newline true continuation_prompt ▸▹ format ($nix_shell$container$fill$git_metrics\n)$cmd_duration\ $hostname\ $localip\ $shlvl\ $shell\ $env_var\ $jobs\ $sudo\ $username\ $character [fill] symbol add_newline true每条命令输出前自动换行保持行首清爽这也是 Starship 默认值见 src/configs/starship_root.rs。continuation_prompt多行命令续行时显示▸▹dimmed white替代默认的∙。format主提示行自上而下依次渲染nix_shell、container、fill、git_metrics随后是cmd_duration、hostname、localip、shlvl、shell、env_var、jobs、sudo、username与character。第一行nix_shell/container是独立成行的括号内内容结尾紧跟\n即以“状态行”形式汇报 Nix shell 与容器信息$fill将剩余宽度填满为空格而git_metrics新增/删除行数被放在同行的末尾视觉上“顶到右边”。第二行才是真正的交互提示行。值得注意普通配置中常见的directory、git_branch并不在这里——它们被刻意移到了右提示。[fill]的symbol 使用空格填充主提示行第一行中段让git_metrics与左侧状态拉开距离。右侧提示行信息的主战场right_format $singularity\ $kubernetes\ $directory\ ... $timeright_format的顺序即右侧信息从左到右的排列次序依次覆盖以下六类信息环境与编排singularity、kubernetes、docker_context、nix_shell容器/虚拟化上下文版本控制directory、vcsh、fossil_branch、git_branch、git_commit、git_state、git_status、hg_branch、pijul_channel——几乎所有 VCS 工具链都被放进了右侧包管理package当前目录的项目包版本语言运行时c、cpp、cmake、cobol、daml、dart、deno、dotnet、elixir、elm、erlang、fennel、fortran、golang、guix_shell、haskell、haxe、helm、java、julia、kotlin、gradle、lua、maven、nim、nodejs、bun、ocaml、opa、perl、php、pulumi、purescript、python、raku、rlang、red、ruby、rust、scala、solidity、swift、terraform、vlang、vagrant、xmake、zig等一整套语言工具链包管理器与运行环境buf、conda、pixi、meson、spack系统状态memory_usage、aws、gcloud、openstack、azure、crystal、custom、status、os、battery、time。也就是说你 cd 进任意项目后语言版本、Git 状态、云平台 profile、内存占用、电量与时间都会在右侧自动汇总展示主提示行则保持只有一个◎prompt 字符的极简形态。关键模块的定制细节character伪极简的“脸面”[character] format $symbol success_symbol ◎ error_symbol ○ vimcmd_symbol ■ # not supported in zsh vimcmd_replace_one_symbol ◌ vimcmd_replace_symbol □ vimcmd_visual_symbol ▼命令成功时显示亮黄◎失败时显示紫色○一眼可辨上次命令的退出状态。进入 vim 模式时切换为绿色■替换/可视模式有各自符号。配置注释特意说明后三者的替换符号◌、□、▼在 zsh 中不受支持仅部分 shell 能区分多种 vim 子模式若你在 zsh 使用 Jetpack这部分符号将不会按预期切换。username 与 sudo[sudo] format $symbol style bold italic bright-purple symbol ⋈┈ disabled false [username] style_user bright-yellow bold italic style_root purple bold italic format ⭘ $user disabled false show_always false显式启用sudo模块Starship 默认关闭仅在检测到有效的 sudo 凭证时显示⋈┈配合身份提示。username平时不显示show_always false只有当用户为 root、通过 SSH 连接或用户名与约定不一致时才出现普通用户前缀⭘root 使用紫色粗体。directory目录展示是右侧的核心[directory] home_symbol ⌂ truncation_length 2 truncation_symbol □ read_only ◈ use_os_path_sep true style italic blue format $path$read_only repo_root_style bold blue repo_root_format $before_root_path$repo_root$path$read_only △家目录缩写为⌂长路径从头部截断、只保留最后 2 层truncation_length 2被省略部分用□表示配合use_os_path_sep true会按各操作系统路径分隔符显示。只读目录追加◈角标。进入 Git 仓库根目录时仓库根以粗体蓝色高亮并在末尾追加[△]标记与git_branch的△图标形成呼应。Git 状态族细颗粒的状态可视化[git_branch] format $branch(:$remote_branch) symbol △ style italic bright-blue truncation_symbol ⋯ truncation_length 11 ignore_branches [main, master] only_attached true [git_metrics] format (▴$added)(▿$deleted) added_style italic dimmed green deleted_style italic dimmed red ignore_submodules true disabled false [git_status] style bold italic bright-blue format (⎪$ahead_behind$staged$modified$untracked$renamed$deleted$conflicted$stashed⎥) conflicted ◪◦ ahead ▴│[${count}│](italic green) behind ▿│[${count}│](italic red) diverged ◇ ▴┤[${ahead_count}│▿┤${behind_count}│](italic bright-magenta) untracked ◌◦ stashed ◃◈ modified ●◦ staged ▪┤[$count│](italic bright-cyan) renamed ◎◦ deleted ✕git_branch默认隐藏main/master分支ignore_branches只在HEAD 直接附着于分支时显示only_attached true避免 detached HEAD 状态下的噪音。git_metrics非默认启用汇报相对上游新增/删除的行数——新增用▴绿、删除用▿红这也是主提示行第一行右侧的内容来源。git_status把未提交改动汇总在⎪…⎥双竖线括号中每一种改动类型都有专属符号与颜色冲突◪◦、领先▴、落后▿、分叉◇、未跟踪◌◦、暂存▪、修改●◦、重命名◎◦、删除✕、stash◃◈其中带计数的地方用bold white数字突出。Jetpack 同样为 jjJujutsu用户定义了jj_bookmark模块样式△图标 忽略main/master与 Git 分支观感保持一致方便混用两类版本控制工具的团队统一体验。语言运行时统一但克制的缩写标签Jetpack 把所有语言模块的展示名压成 24 个字母且保持「斜体标签 彩色版本」的统一版式例如[nodejs] format node ◫ ($version) version_format ${raw} detect_files [package-lock.json, yarn.lock] detect_folders [node_modules] detect_extensions [] [python] format py ${symbol}${version} symbol ⌉⌊ version_format ${raw} style bold bright-yellowversion_format ${raw}直接展示原始版本号去掉多余的前缀修饰保证信息紧凑。nodejs 的探测规则被显式收窄为package-lock.json/yarn.lock与node_modules避免在无关目录误报。类似的缩写规则贯穿全文件Rust 显示为rs、Ruby 为rb、Swift 为sw、Go 为go而 deno、lua、bun 等则以完整小写单词出现。无论哪种语言标签都统一为斜体、无下划线颜色让位给版本号视觉层级非常一致。系统状态与时间[time] disabled false format $time time_format %R utc_time_offset local style italic dimmed white [battery] format $percentage $symbol full_symbol █ charging_symbol ↑ discharging_symbol ↓ unknown_symbol ░ empty_symbol ▃ [[battery.display]] threshold 20 style italic bold red [[battery.display]] threshold 60 style italic dimmed bright-purple [[battery.display]] threshold 70 style italic dimmed yellowtime以 24 小时制%R显示并跟随本地时区localip仅在 SSH 会话中输出ssh_only true亮品红圆点前缀jobs用蓝色▶标记后台任务cmd_duration用◄ …包裹耗时。battery为三档阈值20/60/70设置了红/紫/黄分级样式memory_usage提供ram及可选swap占用。Nix Shell 与环境标注[nix_shell] style bold italic dimmed blue symbol ✶ format $symbol nix⎪$state⎪ $name impure_msg ⌽ pure_msg ⌾ unknown_msg ◌Nix shell 使用✶标记并区分 pure⌾绿/ impure⌽红两种进入方式右侧的docker_context、kubernetes等模块同理只在实际进入相关环境时出现保证「不在其位不谋其政」的信息收敛。完整配置清单以下是 jetpack.toml 的完整内容与starship preset jetpack输出的内容完全一致可作为手工配置或二次开发的基准# version: 1.0.0 $schema https://starship.rs/config-schema.json add_newline true continuation_prompt ▸▹ format ($nix_shell$container$fill$git_metrics\n)$cmd_duration\ $hostname\ $localip\ $shlvl\ $shell\ $env_var\ $jobs\ $sudo\ $username\ $character right_format $singularity\ $kubernetes\ $directory\ $vcsh\ $fossil_branch\ $git_branch\ $git_commit\ $git_state\ $git_status\ $hg_branch\ $pijul_channel\ $docker_context\ $package\ $c\ $cpp\ $cmake\ $cobol\ $daml\ $dart\ $deno\ $dotnet\ $elixir\ $elm\ $erlang\ $fennel\ $fortran\ $golang\ $guix_shell\ $haskell\ $haxe\ $helm\ $java\ $julia\ $kotlin\ $gradle\ $lua\ $maven\ $nim\ $nodejs\ $bun\ $ocaml\ $opa\ $perl\ $php\ $pulumi\ $purescript\ $python\ $raku\ $rlang\ $red\ $ruby\ $rust\ $scala\ $solidity\ $swift\ $terraform\ $vlang\ $vagrant\ $xmake\ $zig\ $buf\ $conda\ $pixi\ $meson\ $spack\ $memory_usage\ $aws\ $gcloud\ $openstack\ $azure\ $crystal\ $custom\ $status\ $os\ $battery\ $time [fill] symbol [character] format $symbol success_symbol ◎ error_symbol ○ vimcmd_symbol ■ # not supported in zsh vimcmd_replace_one_symbol ◌ vimcmd_replace_symbol □ vimcmd_visual_symbol ▼ [env_var.VIMSHELL] format $env_value style green italic [sudo] format $symbol style bold italic bright-purple symbol ⋈┈ disabled false [username] style_user bright-yellow bold italic style_root purple bold italic format ⭘ $user disabled false show_always false [directory] home_symbol ⌂ truncation_length 2 truncation_symbol □ read_only ◈ use_os_path_sep true style italic blue format $path$read_only repo_root_style bold blue repo_root_format $before_root_path$repo_root$path$read_only △ [cmd_duration] format ◄ $duration [jobs] format $symbol$number style white symbol ▶ [localip] ssh_only true format ◯$localipv4 disabled false [time] disabled false format $time time_format %R utc_time_offset local style italic dimmed white [battery] format $percentage $symbol full_symbol █ charging_symbol ↑ discharging_symbol ↓ unknown_symbol ░ empty_symbol ▃ [[battery.display]] threshold 20 style italic bold red [[battery.display]] threshold 60 style italic dimmed bright-purple [[battery.display]] threshold 70 style italic dimmed yellow [git_branch] format $branch(:$remote_branch) symbol △ style italic bright-blue truncation_symbol ⋯ truncation_length 11 ignore_branches [main, master] only_attached true [git_metrics] format (▴$added)(▿$deleted) added_style italic dimmed green deleted_style italic dimmed red ignore_submodules true disabled false [git_status] style bold italic bright-blue format (⎪$ahead_behind$staged$modified$untracked$renamed$deleted$conflicted$stashed⎥) conflicted ◪◦ ahead ▴│[${count}│](italic green) behind ▿│[${count}│](italic red) diverged ◇ ▴┤[${ahead_count}│▿┤${behind_count}│](italic bright-magenta) untracked ◌◦ stashed ◃◈ modified ●◦ staged ▪┤[$count│](italic bright-cyan) renamed ◎◦ deleted ✕ [deno] format deno ∫ $version version_format ${raw} [lua] format lua ${symbol}${version} version_format ${raw} symbol ⨀ style bold bright-yellow [nodejs] format node ◫ ($version) version_format ${raw} detect_files [package-lock.json, yarn.lock] detect_folders [node_modules] detect_extensions [] [bun] format bun ◫ ($version) version_format ${raw} [python] format py ${symbol}${version} symbol ⌉⌊ version_format ${raw} style bold bright-yellow [ruby] format rb ${symbol}${version} symbol ◆ version_format ${raw} style bold red [rust] format rs $symbol$version symbol ⊃ version_format ${raw} style bold red [package] format pkg $symbol$version version_format ${raw} symbol ◨ style dimmed yellow italic bold [swift] format sw ${symbol}${version} symbol ◁ style bold bright-red version_format ${raw} [aws] disabled true format aws $symbol $profile $region style bold blue symbol ▲ [buf] symbol ■ format buf $symbol $version $buf_version [c] symbol ℂ format $symbol($version(-$name)) [cpp] symbol ℂ format $symbol($version(-$name)) [conda] symbol ◯ format conda $symbol$environment [pixi] symbol ■ format pixi $symbol$version ($environment ) [dart] symbol ◁◅ format dart $symbol($version ) [docker_context] symbol ◧ format docker $symbol$context [elixir] symbol △ format exs $symbol $version OTP $otp_version [elm] symbol ◩ format elm $symbol($version ) [golang] symbol ∩ format go $symbol($version ) [haskell] symbol ❯λ format hs $symbol($version ) [java] symbol ∪ format java ${symbol}(${version} ) [jj_bookmark] format $symbol$bookmark($remote)$diverged( \\($overflow_count others\\)) symbol △ style italic bright-blue truncation_symbol ⋯ truncation_length 11 ignore_names [main, master] [julia] symbol ◎ format jl $symbol($version ) [memory_usage] symbol ▪▫▪ format mem ${ram}( ${swap}) [nim] symbol ▴▲▴ format nim $symbol($version ) [nix_shell] style bold italic dimmed blue symbol ✶ format $symbol nix⎪$state⎪ $name impure_msg ⌽ pure_msg ⌾ unknown_msg ◌ [spack] symbol ◇ format spack $symbol$environment源码视角这份配置如何被加载与验证配置入口Jetpack 用到的format、right_format、add_newline、continuation_prompt等都属于 Starship 的全局配置。其默认值与字段声明位于 src/configs/starship_root.rs默认format为$all所有模块自动排列、right_format为空字符串、add_newline默认true。Jetpack 显式覆盖它们正是「伪极简」的结构基础。右提示的解析Starship 把right_format与format同等对待——两套字符串都会经由格式化解析器展开成模块序列主提示与右提示在渲染时各占一条输出通道。预设内容的一致性预设内容在构建期通过include_str!(../docs/public/presets/toml/jetpack.toml)嵌入二进制见 src/print.rs 附近测试因此CLI 输出的配置与仓库中的 TOML 文件永远同步测试还覆盖了--output写入与--force覆盖行为src/print.rs。文档侧的一致性官方预设索引 docs/presets/README.md 中的 Jetpack 条目同样指向这张截图与同名 TOML意味着任何语言的官方文档页含 docs/de-DE/presets/jetpack.md都与实际可执行配置保持一致。个性化扩展建议换掉云厂商模块Jetpack 默认在右侧把aws置为disabled true而保留gcloud、azure、openstack如果你的主力是 AWS删除[aws] disabled true段并把对应的云模块移出right_format即可反向调整。加回丢失的模块部分模块如battery、time之外的crystal、custom已出现在right_format中若你不需要某项直接从right_format删除对应行即可若你需要某个未列出的内置模块在right_format追加其$模块名并到文末补充一段样式即可。切换运行时显示粒度version_format ${raw}是 Jetpack 紧凑风格的关键想显示更完整的版本元信息可改回默认的${version}语义或自定义占位符。与官方 schema 协作文件头部的$schema声明让主流编辑器可以按 config-schema.json 提供补全与校验二次开发时建议保留。总的来说Jetpack 是一份非常适合「信息密集但外观克制」用户群体的基准配置它把 Starship 的双栏渲染能力、基础 ANSI 配色随主题自适应的特性、以及符号化状态表达做到了一个自洽的平衡点。以本文的完整配置为起点你可以放心地增删模块、替换符号与颜色打造自己专属的伪极简提示符。【免费下载链接】starship☄️ The minimal, blazing-fast, and infinitely customizable prompt for any shell!项目地址: https://gitcode.com/GitHub_Trending/st/starship创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表