Setting Up Starship Prompt in a DevContainer

Starship gives every shell the same fast, informative prompt from a single config — ideal for a devcontainer where the team may use different shells. This page installs Starship at image time, initializes it in each shell, and shares one starship.toml.

Prerequisites

You need a devcontainer and a shell to initialize Starship in.

  • Starship installed in the image.
  • An init line in the shell rc (zsh/fish/bash).
  • A shared starship.toml config.

Starship prerequisitesInstall Starship, init it in the shell, share a config, and verify.Installat image timeInitin shell rcConfigstarship.tomlVerifyprompt renders

Step-by-Step Implementation

  1. Install Starship in the image.
RUN curl -fsSL https://starship.rs/install.sh | sh -s -- -y
  1. Initialize it in the shell (zsh shown).
grep -q 'starship init zsh' ~/.zshrc || echo 'eval "$(starship init zsh)"' >> ~/.zshrc
  1. Share one config.
# starship.toml (mounted or copied to ~/.config/starship.toml)
add_newline = false
[git_branch]
symbol = " "
  1. Verify the prompt renders in a new terminal.

Starship modelStarship installs once, initializes per shell, and renders one config across shells.Image installstarship binaryShell initeval starship initstarship.tomlone config, all shellsResultfast, consistent prompt

Common Pitfalls

Starship issues are a missing init line or an unshared config.

Starship triageA triage path from a missing prompt to a consistent cross-shell one.Does the prompt render?NOAdd the init line to the shell rcSame prompt across shells?YESConfig shared, not per-userConsistent prompt

SymptomRoot CauseRemediation
Prompt not showingNo init line in the rcAdd eval "$(starship init )"
Different prompt per developerConfig in personal dotfiles onlyShare starship.toml in the config
Init line duplicatedUnguarded appendGuard with grep before appending
starship not foundNot installed in the imageInstall it in the Dockerfile

Conclusion

Starship gives one prompt for every shell from a single starship.toml. Install it at image time, add a guarded init line to the shell rc, and share the config so the whole team sees the same prompt — fast, informative, and shell-agnostic.

Shared and consistentA shared Starship install and config gives every shell the same fast prompt.SharedStarship binaryOne starship.tomlInit in rcBenefitSame prompt everywhereCross-shellFast startup

FAQ

Why Starship over a shell-specific prompt framework? Starship is cross-shell and compiled, so one config gives zsh, fish, and bash an identical, fast prompt. In a devcontainer where teammates may use different shells, that consistency and speed beats maintaining separate prompt frameworks per shell.

Where should the starship.toml live? Share it through the config (copied or mounted to ~/.config/starship.toml) so everyone gets the same prompt, rather than leaving it in individual dotfiles. Personal tweaks can still layer on, but the shared config sets the team baseline.

How do I keep the init line from duplicating? Guard the append (grep -q 'starship init' ~/.zshrc || echo … >> ~/.zshrc) since the bootstrap re-runs on each create. Or add the init line in the image's shell rc so it's baked in and never appended at runtime.