自动定时在每猛砸执行的命令和show提示? [英] Automatically timing every executed command and show in Bash prompt?
问题描述
我经常会发生忘记明确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屋!