自动定时在每猛砸执行的命令和show提示? [英] Automatically timing every executed command and show in Bash prompt?

查看:125
本文介绍了自动定时在每猛砸执行的命令和show提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常会发生忘记明确preFIX处决时间命令,最好我会在接下来的外壳看到提示多少实时的最后一个命令了(在每个命令)。

I often happen to forget to explicitly prefix executions with the "time" command, ideally I would see in the next shell prompt how much real time the last command took (on every command).

我已通过的bash文档冲刷,但找不到相关的任何东西。

I already scoured through the bash documentation, but couldn't find anything related.

推荐答案

您可以这样做:

$ bind '"\C-j": "\C-atime \C-m"'

或者把这个在你的〜/ .inputrc文件

"\C-j": "\C-atime \C-m"

然后当你想要做的睡眠时间1 您可以输入睡眠1 和preSS <大骨节病>控制 + <大骨节病>Ĵ而不是<大骨节病>输入

Then when you want to do time sleep 1 you'd type sleep 1 and press Ctrl+J instead of Enter.

我不建议在bind命令调换Ĵ M (或在.inputrc文件文件) 。每次你preSS <大骨节病>输入你会得到时间添加这可能是pretty恼人的,并会导致错误打字时多行命令。

I would not recommend swapping the j and m in the bind command (or in the .inputrc file). Every time you'd press Enter you'd get time added which could be pretty annoying and would cause errors when typing a multi-line command.

您可以添加到您的〜/ .bashrc中来使时间更紧凑的输出:

You could add this to your ~/.bashrc to make the output of time more compact:

export TIMEFORMAT='r: %R, u: %U, s: %S'

(类似我的答案<一个href=\"http://serverfault.com/questions/31845/is-there-a-way-to-configure-bash-to-always-page-output/31870#31870\">here.)

这篇关于自动定时在每猛砸执行的命令和show提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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