I use emacs' inferior shells, or just the shell frequently. Since I work mostly on ML algos my commands sometime take a long time. I would like to enable auto-timing of all commands run in emacs shells, so that I don't have to add extra/ugly glue code and I don't have to "pre-think" about timing a run. When I run a command its run time should automatically get logged (printing to a separate buffer would be best) so that if some parameters suddenly take a long time I can note its run-time later. All ideas are welcome, thanks.
One way to take care of this with a workaround is to set your shell prompt to display time, then each time you execute, you will have the previous time stamp and the new time stamp as soon as the job is finished. This will likely require you to press before runnign any command to get a new prompt and renew the dsiplayed time, but this is not a big problem when you want a quick imprecise timer once in a while.
To get a prompt like
EDIT For windows, try
to get something like
Inspired by gt's answer I found a way to do this in python. For python interpreter,
This will add a prompt that looks like
doing only the above would break useful features in python mode like send-region and send-buffer. Basically python mode expects that the prompt would match a particular regexp. (aside: it also means that there is no point in changing the lower, more basic, comint-mode.) Anyway, we change the variable python-shell-prompt-alist in python.el so that it matches the prompt that we have set, then delete python.elc and then restart.
This will match a prompt of type
I have a method that works for me under linux. It depends on the function
This method is not good if you want to use a program inside the shell it does not work, lets say
Here it goes:
In your .emacs file add this.
Whenever I run a command in it looks like this (this example: sleep for 1 second)