Open-Source Wikis

/

Starship

/

Subsystems

/

Configure subcommands

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:

  1. Resolves $EDITOR (or $VISUAL), falling back to vi on Unix and notepad.exe on Windows.
  2. Resolves the config path via Context::get_config_path_os ($STARSHIP_CONFIG or ~/.config/starship.toml).
  3. 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 subtables

This is purely a read operation:

  • Without --default: loads the user's TOML, deserializes into FullConfig, then re-serializes with defaults filled in.
  • With --default: starts with FullConfig::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 in Commands (in src/main.rs), a handler that uses toml_edit::DocumentMut, and tests in src/configure.rs.
  • Change the default editor: edit STD_EDITOR consts in src/configure.rs.
  • Make print-config include unset Option fields: serialize FullConfig differently — currently uses serde's default skip_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.

Configure subcommands – Starship wiki | Factory