怎样才能最后一个命令的挂钟时间的Bash提示符放? [英] How can the last command's wall time be put in the Bash prompt?

查看:130
本文介绍了怎样才能最后一个命令的挂钟时间的Bash提示符放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法嵌入的最后一个命令的墙壁经过一次在猛砸提示?我希望的东西,应该是这样的:

Is there a way to embed the last command's elapsed wall time in a Bash prompt? I'm hoping for something that would look like this:

[last: 0s][/my/dir]$ sleep 10
[last: 10s][/my/dir]$

背景

我经常长时间运行的数据运算工作,是非常有用的知道他们已经采取了多长时间,所以我可以估算它需要多长时间为未来作业。对于非常普通的任务,我继续前进,严格记录使用适当的测井技术信息。对于不太正式的工作,我只是prePEND与时间命令。

I often run long data-crunching jobs and it's useful to know how long they've taken so I can estimate how long it will take for future jobs. For very regular tasks, I go ahead and record this information rigorously using appropriate logging techniques. For less-formal tasks, I'll just prepend the command with time.

这将是很好自动时间每一个交互式命令并打印在几个字符,而不是3行的定时信息。

It would be nice to automatically time every single interactive command and have the timing information printed in a few characters rather than 3 lines.

推荐答案

您可以利用对于bash这个zsh中借用吊钩:<一href=\"http://www.twistedmatrix.com/users/glyph/$p$pexec.bash.txt\">http://www.twistedmatrix.com/users/glyph/$p$pexec.bash.txt

You could utilize this zsh-borrowed hook for bash: http://www.twistedmatrix.com/users/glyph/preexec.bash.txt

与此挂钩(Mac OS X中)来完成时间:使用低吼监控长时间运行shell命令

Timing done with this hook (Mac OS X): Use Growl to monitor long-running shell commands

这篇关于怎样才能最后一个命令的挂钟时间的Bash提示符放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆