twolfson / sexy-bash-prompt

Bash prompt with colors, git statuses, and git branches.
MIT License
1.14k stars 154 forks source link

Added exit code support #89

Closed twolfson closed 4 years ago

twolfson commented 4 years ago

As per #82, we've wanted exit code support for a while and are finally adding it

We discovered the quirk that bash will persist exit codes until a new command is provided so we added a configuration to ignore that

In this PR:

Screenshots:

Selection_218

twolfson commented 4 years ago

@rpdelaney I think this was missed while reviewing #88 as well =/

rpdelaney commented 4 years ago

I saw it. It's looks a bit more complex so I'm waiting until the end of my work day so I can put some more time into looking at it.

twolfson commented 4 years ago

Ah, gotcha. Sounds great. Thanks for your help as always @rpdelaney =)

twolfson commented 4 years ago

Hmm, what's confusing about PROMPT_SHOW_ERROR_ONCE? The scenario it's solving for? Implementation? Something else?

twolfson commented 4 years ago

Deciding to land for now, hopefully we can iterate on clarity in a future PR

twolfson commented 4 years ago

Oh damn it, I forgot to update the base -_-;; Going to see if I can just cherry-pick to master anyway =/

rpdelaney commented 4 years ago

I think I understand what the code is doing more than I understand why it's doing it :)

twolfson commented 4 years ago

:+1: Alright, really verbose explanation of all the scenarios and how we fix them:

Blank terminal

Successful exit code

Non-zero exit code

Keyboard interrupt

What our fix does

Does that clear things up? Is this good enough to link to in the code comments for a verbose explanation?

twolfson commented 4 years ago

Want to add that I've realized my dotfiles has a HISTTIMEFORMAT setting in it which causes a timestamp in my history:

  499  2020-09-07T20:23:57-0700 false
  500  2020-09-07T20:23:57-0700 false
  501  2020-09-07T20:23:58-0700 history 5

The history check still works regardless though as we have the history number in each prompt (i.e. 500/501/etc):

  500  false
  501  history 5
  502  history 5