I have spent an embarrassing amount of my life on my shell prompt. Powerline glyphs, git status with ahead/behind arrows, language version badges, battery, weather, the lot. At one point my prompt told me the phase of the moon and I genuinely could not tell you why. The turning point was watching it lag for half a second on every command inside a large repo, because it was shelling out to a dozen tools before showing me a cursor.
So I tore it down and asked a simpler question. What do I actually need the prompt to tell me, every time, before I press enter? The answer was shorter than my old config by a long way.
The things that earn their place
Four things survived the cull. Where I am, which host, whether the last command failed, and a clear marker when I am somewhere dangerous.
The path matters because I am always one terminal away from being in the wrong directory. The host matters because I am frequently SSH'd into something and a destructive command on the wrong box is a bad afternoon. The exit status of the last command matters because failures are quiet and I miss them otherwise. And the danger marker is the one I would keep above all the others.
That last one is the whole point of this post, really. When I am on a production host, or my kube context is pointed at a cluster that matters, the prompt changes colour and tells me so in plain words. Red background, the cluster name, no ambiguity. I would rather give up every other feature than lose that, because it is the one that has actually saved me from running the right command in the wrong place.
Keeping it fast
The other rule I gave myself was that the prompt must not block. Anything that touches the network, or walks a large directory tree, gets computed asynchronously or not at all. Git status is the usual culprit here, and in a big repo a naive git status on every prompt is genuinely slow. Starship handles this well out of the box, with sensible timeouts, so these days I let it do the work rather than hand-rolling shell functions.
A trimmed version of what I run looks like this:
[kubernetes]
disabled = false
format = '[$context]($style) '
[kubernetes.context_aliases]
"prod-.*" = "PROD"
[git_status]
disabled = false
[cmd_duration]
min_time = 2000
The cmd_duration line is a small joy. Anything that takes more than two seconds gets its runtime printed when it finishes, so I notice the slow things without having to wrap them in time. It has quietly caught a few commands that were slower than I assumed.
The lesson, if there is one, is that a prompt is a heads-up display and not a dashboard. A dashboard is something you look at when you choose to. A prompt is in your face on every line, so every element it shows is a small tax on your attention. The moon phase was not paying its way. The "you are on production" marker pays for the whole thing on its own.