starship/starship
Configure subcommands
The starship config, starship print-config, and starship toggle subcommands. All three live in src/configure.rs.
starship config
starship config # Open $EDITOR on starship.toml
starship config <key> <value> # Set a key to a value
starship config <key> # Error: must also pass <value>The "open in editor" path:
- Resolves
$EDITOR(or$VISUAL), falling back tovion Unix andnotepad.exeon Windows. - Resolves the config path via
Context::get_config_path_os($STARSHIP_CONFIGor~/.config/starship.toml). - Spawns the editor synchronously.
The "set a key" path uses toml_edit to preserve comments and formatting:
fn handle_update_configuration(doc: &mut DocumentMut, name: &str, value: &str) -> Result<(), String> {
// Walk dotted path, creating tables as needed
// Parse value as TOML literal first; fall back to string
// Preserve original decor (comments, whitespace, indentation)
}Dotted keys like git_status.disabled = true walk nested tables; non-existent intermediate tables are created on demand. The new value is parsed as a TOML expression first (so true, 42, "text" round-trip correctly), then falls back to a string literal.
starship print-config
starship print-config # Show the current effective config
starship print-config --default # Show every default value
starship print-config <key> [<key>...] # Print only specific subtablesThis is purely a read operation:
- Without
--default: loads the user's TOML, deserializes intoFullConfig, then re-serializes with defaults filled in. - With
--default: starts withFullConfig::default()and serializes that. - With
<key>arguments: walks into the named subtables and prints just those.
The output is a TOML representation that can be saved as a starting point for customization. The implementation note # Warning: This config does not include keys that have an unset value reminds users that Option<T> fields with None are skipped.
starship toggle
starship toggle <module> # Toggle <module>.disabled
starship toggle <module> <key> # Toggle <module>.<key>Reads the current value of <module>.<key> (default key: disabled), inverts it, and writes back via the same toml_edit mechanism as starship config. Used by users who want a quick way to disable or re-enable a module without an editor.
Why toml_edit matters
Round-tripping TOML through toml::Value loses comments and reorders keys. toml_edit::DocumentMut is a lossless representation that preserves whitespace, comments, and key order. Starship uses it for any code path that mutates the user's TOML, even though the read paths (StarshipConfig::initialize) use the simpler toml crate.
Entry points for modification
- New subcommand for editing TOML (e.g.,
starship unset <key>): add a variant inCommands(insrc/main.rs), a handler that usestoml_edit::DocumentMut, and tests insrc/configure.rs. - Change the default editor: edit
STD_EDITORconsts insrc/configure.rs. - Make
print-configinclude unset Option fields: serializeFullConfigdifferently — currently uses serde's defaultskip_serializing_if = "Option::is_none"style behavior.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.