Starship Cross-Shell Prompt

website·Indexed 39 days ago

https://starship.rs/

A customizable cross-shell prompt that works on most common shells and operating systems. Features include a wide variety of community configuration presets (such as Tokyo Night, Gruvbox Rainbow, and Pure), advanced configuration options via starship.toml, and support for TransientPrompt across PowerShell, Cmd, Fish, and Bash.

Tokens
43.5K
Snippets
289
Records
355
Agent score
73%

What's inside Starship

  1. Available Starship configuration presets

    Starship provides a variety of community-submitted presets to customize the look and behavior of the prompt. These include:

    • Visual/Theme Presets:

      • Pure Prompt: Emulates the Pure prompt look and behavior.
      • Pastel Powerline: Inspired by M365Princess; demonstrates path substitution.
      • Tokyo Night: Inspired by the tokyo-night-vscode-theme.
      • Gruvbox Rainbow: A colorful, rainbow-style prompt.
      • Catppuccin Powerline: A version of Gruvbox Rainbow using the Catppuccin palette.
      • Jetpack: A pseudo-minimalist style inspired by geometry and spaceship prompts.
    • Symbol & Font Presets:

      • Nerd Font Symbols: Updates module symbols to use Nerd Font icons.
      • No Nerd Fonts: Removes all Nerd Font symbols (planned to become the default in a future release).
      • Plain Text Symbols: Replaces symbols with plain text for environments without Unicode support.
    • Functional/Layout Presets:

      • Bracketed Segments: Replaces default wording (like "via" or "on") with brackets around segments.
      • No Runtime Versions: Hides language runtime versions, ideal for containerized or virtualized environments.
      • No Empty Icons: Prevents icons from appearing if the associated toolset is not found.
  2. Configure the C++ compiler module in Starship

    The cpp module shows information about the C++ compiler. This module is disabled by default and must be explicitly enabled by setting disabled = false. It triggers on files with extensions like .cpp, .hpp, .cc, etc.
    # ~/.config/starship.toml
    [cpp]
    disabled = false
    format = 'via [$name $version]($style)'
  3. Configure the C compiler module in Starship

    The c module shows information about the C compiler. It triggers by default if the directory contains .c or .h files. You can customize the detection logic using the commands option, which takes a list of executable names and arguments (e.g., ['cc', '--version']).
    # ~/.config/starship.toml
    [c]
    format = 'via [$name $version]($style)'
    # Example of custom detection commands:
    # commands = [[ 'cc', '--version' ], [ 'gcc', '--version' ], [ 'clang', '--version' ]]
  4. Configure the C++ compiler module in Starship

    The cpp module displays information about the C++ compiler. It is triggered by files with extensions such as .cpp, .hpp, .cc, etc. Note that this module is disabled by default and must be explicitly enabled by setting disabled = false.
    # ~/.config/starship.toml
    
    [cpp]
    disabled = false
    format = 'via [$name $version]($style)'
  5. Configure the C compiler module in Starship

    The c module displays information about the C compiler. It is triggered by default if the directory contains .c or .h files. The commands option allows you to specify a list of executables (e.g., ['gcc', '--version']) that Starship will try to execute to detect the compiler name and version.
    # ~/.config/starship.toml
    
    [c]
    format = 'via [$name $version]($style)'
  6. Starship shell prompt compatibility

    Starship is designed to be compatible with the most common shells across the most common operating systems, allowing it to be used in diverse environments.
  7. Customize the Character module in Starship

    The character module displays a character (typically an arrow) at the end of the prompt. It indicates the success or failure of the previous command by changing its color (red/green) or its shape (e.g., ❯ vs ✖).
  8. Install the Catppuccin Powerline Starship preset

    The Catppuccin Powerline preset is a powerline-style prompt based on the Catppuccin theme palette. It requires a Nerd Font to be installed and enabled in the terminal to render the glyphs correctly.
    starship preset catppuccin-powerline -o ~/.config/starship.toml
  9. Install the Gruvbox Rainbow preset for Starship

    The Gruvbox Rainbow preset provides a colorful, powerline-inspired prompt. To use this preset, you must have a Nerd Font installed and enabled in your terminal to render the required symbols.
    starship preset gruvbox-rainbow -o ~/.config/starship.toml
  10. Apply the Nerd Font Symbols preset to Starship

    The Nerd Font Symbols preset replaces the default symbols for various Starship modules with Nerd Font icons. To use this preset, you must have a Nerd Font installed and active in your terminal (e.g., Fira Code Nerd Font).
    starship preset nerd-font-symbols -o ~/.config/starship.toml
  11. Run custom pre-prompt and pre-execution commands in Cmd

    In Cmd (via Clink), you can execute custom logic in starship.lua using specific hook functions:

    • starship_preprompt_user_func(prompt): Runs right before the prompt is drawn.
    • starship_precmd_user_func(line): Runs right before a command is executed.
    function starship_preprompt_user_func(prompt)
      print("🚀")
    end
    
    function starship_precmd_user_func(line)
      print("Executing: "..line)
    end
    
    load(io.popen('starship init cmd'):read("*a"))()
  12. Apply the No Empty Icons preset in Starship

    The 'No Empty Icons' preset modifies Starship's behavior so that toolset icons are displayed only if the toolset information (such as the version number) can be determined. By default, Starship may display an icon if toolset files are identified even if the version cannot be found; this preset prevents that behavior.
    starship preset no-empty-icons -o ~/.config/starship.toml