I would like to press a selected hotkey to paste a timestamp in the YYYYMMDDHHmmSS format 20180509145153 immediately, like AutoHotKey allows on Windows.

  • 2
    What is your operating environment? Linux, NetBSD, Solaris? And GUI (which?) or text console?
    – Jeff Schaller
    May 9, 2018 at 14:14

2 Answers 2


You could do it at different levels depending on where you want it to happen. For instance, you could configure your shell or prefered text editor to do that, but that would only affect them.

Or you could configure screen/tmux or your terminal emulator to do it, and it would affect commands running in that terminal emulator when the terminal emulator is the active window.

Under X11, you could use xbindkey to handle a specific key or key combination and have it simulate a series of keypress and keyrelease events (using xte or xdotool for instance). Which would work for any application connecting to the same X server and is active.

For instance, add to your ~/.xbindkeysrc:

"sleep 0.1; xdotool type --clearmodifiers $(date +%Y%m%d%H%M%S)"

for that timestamp to be sent as a series of key press upon Ctrl+Space. (I find that if I don't add the sleep 0.1, I'm sometimes missing the start of the timestamp).

Another option would be to store the timestamp as the PRIMARY X11 selection, and simulate a middle mouse button click, which for many application causes the content of the PRIMARY selection to be inserted at the current mouse pointer position. In ~/.xbindkeysrc:

"date +%Y%m%d%H%M%S | tr -d '\n' | xclip; sleep 0.1; exec xdotool click --clearmodifiers 2"

You could do it with different scripts in different OS.

AutoKey in Linux

The AutoKey Python script language is used for the following solution. Tested in my KUbuntu version 20.04 (based on Ubuntu).

Set the Hotkey in the AutoKey GUI is self-explanatory (for e.g. Meta+n)

# output = system.exec_command("date") # Sa 20. Feb 09:38:39 CET 2021
output = system.exec_command("(date +%Y%m%d%H%M%S)") # 20210220093839

AutoHotkey in Linux

You can also use AutoHotkey in Linux (some settings with Wine are necessary).

Here is an example Github solution: https://github.com/sl5net/Lintalist4Linux . Its using the tip's written in https://ubuntuhandbook.org/index.php/2020/01/install-wine-5-0-stable-ubuntu-18-04-19-10/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .