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

a shell prompt that earns its keep

How I tuned my Starship prompt to show only the context I actually act on, and dropped everything that was just noise.

A keyboard and terminal on a desk

A prompt has one job: tell me what I need to know before I run the next command, and nothing else. For a long time mine failed at the second half. It showed a battery indicator on a desktop, a username that never changed, a hostname I already knew, and three different version strings for languages I wasn't using in that directory. All of that costs you a fraction of a second of reading every single time you look down, and you look down a lot.

I moved to Starship a while back and the real work was deletion, not configuration. The defaults are reasonable but generous. I want a prompt that's nearly empty when there's nothing to say and loud when there is.

The rule I settled on: only surface things that change what I'm about to type. So the prompt shows the working directory, the git branch and whether the tree is dirty, the exit code of the last command but only when it failed, and the Kubernetes context but only when one is set. Everything else is gone.

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

[username]
disabled = true

[hostname]
disabled = true

[kubernetes]
disabled = false
format = '[$context]($style) '

[cmd_duration]
min_time = 2000
format = 'took [$duration]($style) '

[character]
success_symbol = '[\$](green)'
error_symbol = '[\$](red)'

A couple of those are quietly the best part. cmd_duration with min_time = 2000 tells me how long something took, but only when it took more than two seconds, so a quick ls stays silent and a slow build announces itself. The error indicator is just the prompt character going red when the last exit code was non-zero. That single colour change has saved me more than once: a command I thought worked, quietly didn't, and the red $ caught my eye before I carried on.

The Kubernetes context is the one I'm most glad I kept. Most of the time it's blank. When I've got a cluster targeted it appears, and seeing prod sat in my prompt is a useful pause before a kubectl delete. It's a small thing standing between me and a genuinely bad afternoon.

What I deliberately left off: language version blocks. I almost never need to know the Node or Go version from the prompt; if I do, asking is one command. Having it permanently lit just to be there is the kind of clutter I was trying to escape. Same with the time, the username and the host on machines where none of them vary.

The result is a prompt that's two short lines, mostly the path, that goes quiet when there's nothing to report and gets my attention when there is. It took an afternoon and I've not touched it since. That's the sign it's right: I stopped noticing it, which is exactly the point.