Convenient date/time stamping console interaction e.g. using shell aliases?

So, I often find that I really want to know when I started a process (or script) after I discovered that it was taking ages.. meaning I couldn’t pre-pend date before and after it on the command line (without interrupting something I now know takes ages).. and then the process may finish while I’m away from the terminal.

That got me thinking – is it possible to contort shell aliasing such that by default a ‘date’ is invoked before and after every command line entry? It would be super-useful to sometimes be able to scroll back in the terminal and get a feel of how long stuff took.

Do other people have clever ways of addressing this – I’m sure it’s a common enough scenario.

In terms of solutions with this approach, I’m guessing it’s related a bit to this Q.
Run an interactive bash subshell with initial commands without returning to the ("super") shell immediately

where it’s clear you can prepend commands.. but that’s only a part of the solution. Perhaps pre-pending and then getting the shell prompt to show current time would be a fairly neat solution?



Leave a Reply