• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

怎样才能最后命令的挂钟时间的Bash提示符放

用户头像
it1352
帮助1

问题说明

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

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.

正确答案

#1

您可以利用对于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

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhceabhj
系列文章
更多 icon
同类精品
更多 icon
继续加载