The prompt I'd been carrying around for years told me almost nothing useful. Username, host, a truncated path. Fine for 2009. Useless the day you have four terminals open across two clusters and you run the right command in the wrong one. I finally fixed it, and the thing that makes the difference isn't pretty colours, it's the kube context sitting right next to the cursor in red whenever it contains the word "prod".
The other piece I'd resisted for too long is git status in the prompt. Branch name, plus a dirty marker if there are uncommitted changes. I used to think it was noise. Now I think running git status to answer "which branch am I on" was the noise, and the prompt should just carry it.
parse_git_branch() {
git rev-parse --abbrev-ref HEAD 2>/dev/null
}
kube_ctx() {
kubectl config current-context 2>/dev/null
}
PS1='\w $(parse_git_branch) [$(kube_ctx)] \$ '
That's the bones of it. The real version colours the kube context red on anything matching prod, which has already saved me from one kubectl delete aimed at entirely the wrong place. A prompt's whole job is to answer "where am I and is it safe" without my having to ask. Mine finally does.