Closed twolfson closed 4 years ago
After thinking about it for a bit, I think this is good for a personal customization on the shell but feels weird to apply it to everyone
We had a long discussion about this in #80 and I'm of the opinion it should be something that's in a fork
I'll explore adding this into my dotfiles
and maybe link back to it on this issue but closing it for now
Got a working version in https://github.com/twolfson/dotfiles/blob/aca2c34b35d1d626e4c1471f3f2863aea652c93b/.bashrc#L379-L420
It's not quite part of the shell but that's mostly due to me not forking. Also clearly a lot of customization/tweaking I'll want to do with this as I work with it more (e.g. git add -p
is technically a long running command)
e.g. git add -p is technically a long running command
I've noticed this using the same feature in starship
- I rely on the terminal multiplexer a lot, and sometimes I'll have my editor open in this or that file for a long time before I get back to it and finish what I was doing. It can create some amusing runtime reports. It doesn't seem to hurt anything from a UI perspective, but I suppose you could put a cap on it? That is, any runtime value over the limit won't be reported.
Yea, a cap would work -- though I feel it defeats the purpose. My main scenario is timing a long running script but forgetting to append time
to the invocation
I'm now realizing that there's probably other ways to go about this (e.g. process watcher with "close enough" accuracy), but I think exploring this avenue seemed the most straightforward
And yea, not too annoying for now, with occasionally interesting stats (e.g. downsizing those 10 JPGs took 4 seconds, not nothing as in my head)
Got a little inspired by our chat and wrote this time_pid
function in my dotfiles
. There's more robust libraries out there but this is more portable for if I ever want it on a server
(should be as easy as Ctrl+Z, bg
, dump time_pid
, and run time_pid
against pid
from bg
or in jobs -l
-- finally learned about bg
today ._.)
https://github.com/twolfson/dotfiles/blob/98940b9710852fda7aa913bbbb3ed1c75a51600d/.bashrc#L426-L464
Sometimes tasks can take a while to run, it would be great to get a readout of how long a task took to run. I've looked this up previously and I believe it's possible in
bash
via traps:https://jakemccrary.com/blog/2015/05/03/put-the-last-commands-run-time-in-your-bash-prompt/
We should probably only show the timer when the task takes over 10 seconds (maybe make this a configurable setting if someone requests it):