productivity – Monitor your terminal / file change activity

I’m trying to monitor all my activity to optimize productivity and I’m wondering if a system already exists to do so or how to set one up otherwise.

For example, I want to record the programs I execute on the command line and then track the diffs to my files to see how many times I run certain tests and patterns of test updates and code rewriting.

Essentially, I just want to track what I’m doing and figure out how to do it faster.

One hypothesis is that the 2 seconds it takes to run my unit test actually turns into 20 seconds on average because I forget what I was going to do depending on the test output.

Any ideas on how to set this up?