☼
⌃
☰

Starship

Table of Contents

Cross-shell prompt written in Rust. Displays context-aware information (git branch, language version, exit code) without slowing down the prompt. Configured via a single TOML file at ~/.config/starship.toml. Requires a Nerd Font in the terminal for icons to render correctly.

Related: Bash

Installation

SHELL
# Universal installer (Linux / macOS)
curl -sS https://starship.rs/install.sh | sh

# Nix
nix-env -iA nixpkgs.starship

# macOS
brew install starship

# Windows (winget)
winget install --id Starship.Starship

Shell Hook

Add to the end of your shell config:

SHELL
# Bash (~/.bashrc)
eval "$(starship init bash)"

# Zsh (~/.zshrc)
eval "$(starship init zsh)"

# Fish (~/.config/fish/config.fish)
starship init fish | source

# PowerShell (~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1)
Invoke-Expression (&starship init powershell)

Configuration

Config file: ~/.config/starship.toml

SHELL
# Create config file
mkdir -p ~/.config && touch ~/.config/starship.toml

# Open for editing
$EDITOR ~/.config/starship.toml

Useful Modules

TOML
# ~/.config/starship.toml

# Prompt format — reorder or remove modules
format = """
$username\
$hostname\
$directory\
$git_branch\
$git_status\
$python\
$rust\
$nodejs\
$cmd_duration\
$line_break\
$character"""

[directory]
truncation_length = 3         # show last 3 path segments
truncate_to_repo = true       # truncate to git root

[git_branch]
symbol = " "

[git_status]
conflicted = "⚡"
ahead = "⇡${count}"
behind = "⇣${count}"
diverged = "⇕⇡${ahead_count}⇣${behind_count}"
modified = "!"
untracked = "?"
staged = "+"

[python]
symbol = " "
detect_extensions = ["py"]

[cmd_duration]
min_time = 2_000              # show duration if command took > 2s
format = "took [$duration]($style) "

[character]
success_symbol = "[❯](green)"
error_symbol = "[❯](red)"    # red on non-zero exit code

Presets

SHELL
# Apply a community preset (overwrites existing config)
starship preset nerd-font-symbols -o ~/.config/starship.toml
starship preset no-nerd-font -o ~/.config/starship.toml
starship preset gruvbox-rainbow -o ~/.config/starship.toml

# List available presets
starship preset --list

Tips

  • Nerd Fonts are required for most icons — install one and set it as your terminal font before configuring icon modules
  • cmd_duration with min_time set to 2000ms is one of the most useful modules for security work — tells you at a glance when a command took longer than expected without cluttering the prompt
  • The red character on non-zero exit code is a quick visual signal that the last command failed — worth setting up
  • Run starship explain to see which modules are active in the current directory and why
  • starship timings shows how long each module took to render — useful if the prompt feels slow