logoalt Hacker News

deathanatosyesterday at 5:13 PM4 repliesview on HN

As a counterpoint, one of the most useful customizations I've made to my prompt is to emit the exit status of the prior command. Knowing that something failed is a useful signal, esp. when sometimes the thing failing just fails to emit any output that indicates that it failed.

I only emit it if the prior command fails, too, so it doesn't clutter things the 90% of the time things are working.

  » true
  » false
  (last command returned 1.)
  » 
I also translate signals, so I get "last command exited on SIGSEGV", or so.

It's also useful the other way: when a program emits and error and exits with "success".


Replies

wocramtoday at 2:28 AM

This and command duration if the command ran longer than 10 seconds are the most useful things to add.

tclancyyesterday at 7:12 PM

Oh, how do you automate that? I usually add a "& say done | say failed" to long-running tasks if I remember to do it.

__floatyesterday at 6:33 PM

I like the exit code feature a lot; Starship does that with my config in a subtle color change.

My shell customization is largely throwing Starship in (so it looks the same on all the machines I use -- Ubuntu servers at work, macOS at home, nixOS/Fedora/etc. servers for personal use.) and a starship.toml I wrote once and now leave alone.

m000yesterday at 6:40 PM

That's useful indeed. Did you custom-code it, or is it e.g. an ohmyzsh plugin or something?