1 comment

[ 2.6 ms ] story [ 14.5 ms ] thread
Another way you could do this is just put the current epoch time into a variable when a shell is spawned. You can then subtract it from the time when the prompt PS1 is updated. Add a little math function and you could have how many minutes that shell has been in use each time you hit enter, right in the prompt. This method avoids writing to disk. Here is one overly complicated example [1] but you could extend it to be time elapsed since you started the shell. Or do both.

[1] - https://unix.stackexchange.com/questions/485798/show-time-el...