zsh-users
 help / color / mirror / code / Atom feed
* How do I accomplish this?
@ 2017-01-26 20:19 Kannan Varadhan
  2017-01-26 20:33 ` Dominik Vogt
  0 siblings, 1 reply; 3+ messages in thread
From: Kannan Varadhan @ 2017-01-26 20:19 UTC (permalink / raw)
  To: zsh-users

Some of the commands I run seem to take a long time, but also varying 
amounts of time.

I'd like to prefix "time" to every command that runs.  So that,

when I type:


     % make long-running-target

I'd like to see the equivalent of:


     % time make long-running-target

     ...

     make long-running-target     0.00s user 0.00s system 66% cpu 0.004 
total


I thought preexec() might help:


     preexec() {

         set $3

         eval time "$@"

     }


but this ends up running the same command twice, once timed, and once 
without.


Kannan



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How do I accomplish this?
  2017-01-26 20:19 How do I accomplish this? Kannan Varadhan
@ 2017-01-26 20:33 ` Dominik Vogt
  2017-01-26 23:22   ` Kannan Varadhan
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Vogt @ 2017-01-26 20:33 UTC (permalink / raw)
  To: zsh-users

On Thu, Jan 26, 2017 at 12:19:10PM -0800, Kannan Varadhan wrote:
> Some of the commands I run seem to take a long time, but also
> varying amounts of time.
> 
> I'd like to prefix "time" to every command that runs.  So that,
> 
> when I type:
> 
> 
>     % make long-running-target
> 
> I'd like to see the equivalent of:
> 
> 
>     % time make long-running-target
> 
>     ...
> 
>     make long-running-target     0.00s user 0.00s system 66% cpu
> 0.004 total
> 
> 
> I thought preexec() might help:
> 
> 
>     preexec() {
> 
>         set $3
> 
>         eval time "$@"
> 
>     }
> 
> 
> but this ends up running the same command twice, once timed, and
> once without.

Setting REPORTTIME does the trick:

  REPORTTIME=1  # stats for procs using 1 or more seconds

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How do I accomplish this?
  2017-01-26 20:33 ` Dominik Vogt
@ 2017-01-26 23:22   ` Kannan Varadhan
  0 siblings, 0 replies; 3+ messages in thread
From: Kannan Varadhan @ 2017-01-26 23:22 UTC (permalink / raw)
  To: zsh-users

Nice.  I didnt know where to look for it,

THanks,

Kannan


On 1/26/17 12:33 PM, Dominik Vogt wrote:
> On Thu, Jan 26, 2017 at 12:19:10PM -0800, Kannan Varadhan wrote:
>> Some of the commands I run seem to take a long time, but also
>> varying amounts of time.
>>
>> I'd like to prefix "time" to every command that runs.  So that,
>>
>> when I type:
>>
>>
>>      % make long-running-target
>>
>> I'd like to see the equivalent of:
>>
>>
>>      % time make long-running-target
>>
>>      ...
>>
>>      make long-running-target     0.00s user 0.00s system 66% cpu
>> 0.004 total
>>
>>
>> I thought preexec() might help:
>>
>>
>>      preexec() {
>>
>>          set $3
>>
>>          eval time "$@"
>>
>>      }
>>
>>
>> but this ends up running the same command twice, once timed, and
>> once without.
> Setting REPORTTIME does the trick:
>
>    REPORTTIME=1  # stats for procs using 1 or more seconds
>
> Ciao
>
> Dominik ^_^  ^_^
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-26 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 20:19 How do I accomplish this? Kannan Varadhan
2017-01-26 20:33 ` Dominik Vogt
2017-01-26 23:22   ` Kannan Varadhan

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).