问题描述
下面是会发生什么,将显示在指定的时间等待关键preSS,如果没有关键preSS然后将恢复的消息。
Here's what will happen, a message is displayed with a specified time waiting for keypress, if no keypress then it will resume.
示例
preSS ESC退出,否则你会死.. 3..2..1
"Press ESC to exit, otherwise you will die.. 3..2..1"
preSS'X'拖延和检查电子邮件,阅读一些博客,Facebook,微博..否则你将恢复12小时工作.. 3..2..1
"Press 'x' to procrastinate and check email, read some blogs, facebook, twitter.. otherwise you will resume work for 12 hours.. 3..2..1"
这应该是一个非常方便的功能。我如何在bash创建此功能?
This should be a really handy function. How do I create this functionality in bash?
推荐答案
看bash的man页上的读命令,并注意-t超时选项。像这样的东西应该让你开始
Look on the bash man page for the "read" command and notice the "-t timeout" option. Something like this should get you started
for i in 3 2 1 ; do
read -p $i... -n 1 -t 1 a && break
done
这篇关于如何实现在bash定时器键preSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!