From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29223 invoked by alias); 26 Jan 2017 21:18:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22428 Received: (qmail 27706 invoked from network); 26 Jan 2017 21:18:40 -0000 X-Qmail-Scanner-Diagnostics: from mx0b-001b2d01.pphosted.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(148.163.158.5):SA:0(-1.9/5.0):. Processed in 1.113788 secs); 26 Jan 2017 21:18:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: vogt@linux.vnet.ibm.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at linux.vnet.ibm.com does not designate permitted sender hosts) Date: Thu, 26 Jan 2017 21:33:33 +0100 From: Dominik Vogt To: zsh-users@zsh.org Subject: Re: How do I accomplish this? Reply-To: vogt@linux.vnet.ibm.com Mail-Followup-To: zsh-users@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17012620-0032-0000-0000-00000711D552 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17012620-0033-0000-0000-00002337D58B Message-Id: <20170126203333.GA15148@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-26_13:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701260196 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