如何创建插入时间戳的选项?

用户名

在编辑文本文档时,我需要经常放置时间戳记。我想到了以两种不同的方式来自动化它。这些似乎都不起作用。

  1. 使用鹦鹉螺动作

我设置了一个新的右上下文操作,该命令运行 date|xclip

在此处输入图片说明

当我右键单击其他应用程序(例如终端或浏览器)时,不会显示此右键上下文。而且,当它出现并且我单击它时,它什么也没做。

  1. 使用键盘快捷键

我设置了一个新的键盘快捷键,该快捷键应该可以执行date命令,但不能执行命令。

在此处输入图片说明

有指针吗?

谢谢。

机械蜗牛

GNOME键盘快捷键应该可以使用。

Here's why what you tried didn't work: Your keyboard shortcut runs the date command, but does nothing with the output (which just gets discarded). You should pipe it to xclip, as date | xclip to copy it to the X selection (not clipboard). Then you can paste it into your document by middle-clicking. If you want to be able to use Ctrl-V, instead use date | xclip -selection c to copy it to the actual clipboard.

Another alternative is to use xdotool to type the date directly into your document. Assign to your shortcut

xdotool type "$(date)"

Then, when you press the shortcut key, it will calculate the current date and type the characters it into your document.

For ISO 8601 format, use xdotool type "$(date --rfc-3339=s)".


如果不起作用:由于这些是Shell命令(而不是可执行文件),因此bash在快捷方式中指定命令可能必须将命令传递给您的命令将是:

bash -c 'xdotool type "$(date --rfc-3339=s)"'

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章