Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've just switched to zsh. However, I really don't like how the time builtin command also outputs the command that it's timing. I much prefer the bash style output. Anyone know how to switch it over?

Zsh:

[casqa1:~/temp]$ time grep foo /dev/null
/usr/local/gnu/bin/grep --color -i foo /dev/null  0.00s user 0.00s system 53% cpu 0.004 total

Bash:

[casqa1:~/temp]$ bash
casqa1.nyc:~/temp> time grep foo /dev/null

real        0.0
user        0.0
sys         0.0

Thanks,

/YGA

share|improve this question
add comment

3 Answers 3

up vote 11 down vote accepted

This is fairly close:

$ TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S'

$ time sleep 1

real    1.01s
user    0.00s
sys     0.00s
share|improve this answer
    
thanks - beautiful! –  YGA Nov 18 '09 at 18:34
add comment

Just a small precision regarding Dennis Williamson's very useful answer (the "fairly close" part): bash's built-in time outputs to stderr, while zsh's outputs to stdout.

This command can illustrate the difference: time (echo abc) 2>/dev/null

In bash, it outputs:

    $ time (echo abc) 2>/dev/null
    abc

In zsh, with the suggested TIMEFMT variable:

    $ time (echo abc) 2>/dev/null
    abc

    real    0.00s
    user    0.00s
    sys     0.00s
share|improve this answer
add comment

Another option is to disable the builtin command and use the time binary provided by your operating system. I have the following in my .zshrc:

disable -r time       # disable shell reserved word
alias time='time -p ' # -p for POSIX output

This way time outputs to STDERR.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.