Flipping Tables: A Custom Bash Prompt
I’ve been with vanilla Terminal and bash for forever now. I had a brief stint with zsh, but even the extremely slight load delay was too much for me. So I turned to customizing my trusty old bash shell.
? is a value-storing entity. Referencing it with
$? yields the exit status of the last-executed command! I thought it’d be fun to use it to power whimsical bash prompt.
I ended up deciding on the table-flipping dude. He would sit there, calmly next to his table. At the first sight of an error, he’d flip it. Then, if I corrected my ways, he’d set the table back down. If I made 2 or more errors in a row, he’d go into super-angry mode. To accomplish this, I’d keep track of two variables,
lastErr, updating them according to
$?. Here’s the meat of it:
And the results:
All in all, a pretty fun addition to my routine. ◼