Ramblings of an aging IT geek
← Ramblings of an aging IT geek
tooling

a shell prompt that tells me what i actually need

Trimming a bloated shell prompt down to the handful of signals that genuinely prevent mistakes, using Starship.

A mechanical keyboard beside a terminal

My prompt had become a status bar for things I never read. Git branch, git dirty state, language versions for five languages I wasn't using in that directory, the time, a battery icon, a little aeroplane for I forget what. It looked impressive in a screenshot and told me nothing in practice, because when everything is highlighted, nothing is. So I tore it down and rebuilt it around a single question: what would stop me making a mistake?

The answer turned out to be short. Where am I, which git branch, is the working tree dirty, did the last command fail, and crucially, which Kubernetes context and namespace am I pointed at. That last one because the only genuinely dangerous mistakes I make at a terminal involve running the right command against the wrong cluster.

Code on a screen

I use Starship for this now, because it's fast and the config is one readable TOML file rather than a wall of escape codes. The whole thing is mostly about turning modules off:

format = """
$directory$git_branch$git_status$kubernetes$character"""

[kubernetes]
disabled = false
format = '[$context($namespace)](bold red) '

[git_status]
format = '([$all_status$ahead_behind]($style) )'

[battery]
disabled = true

[nodejs]
disabled = true

The kubernetes module is the star. It's red, it's loud, and it sits there reminding me which context I'm in whenever a kubeconfig is active. I made it deliberately ugly so it catches the eye, because a subtle reminder is one you stop seeing. The day it stopped me running a delete against production instead of staging, it paid for itself and every minute I spent configuring it.

The exit-status indicator earns its place too. My prompt character goes red when the last command failed, which sounds trivial, but it means I notice a non-zero exit immediately rather than blindly typing the next thing on top of a failure. Small signal, constant value.

Everything else got cut. I removed the language version modules because I almost never care, and on the rare occasion I do, node --version is right there. I removed the clock because my terminal multiplexer already shows it. The result is a prompt that's nearly empty most of the time and goes loud exactly when it should, which is the whole job of a prompt: be quiet until there's something worth saying. Mine had forgotten that. It's remembered now.