I would like to record the exit code of all shell commands from a specific TTY without additional syntax per command.
For example:
> source solution.sh # sets up this bash session to monitor exit codes
> ls
> ls f
ls: f: No such file or directory
> echo "hello world"
Some file would store exit codes:
0
1
0
Is this possible? If not, I am open to other ideas that might accomplish something similar.
My end goal is to collect data on all of my executed commands and their exit codes (kind of like ~/.bash_history
with exit codes appended)