> ## Content Index
> Fetch the complete content index at: https://www.autodidacts.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# It’s surprisingly hard to reliably paste the current date at the cursor on Linux
- URL: https://www.autodidacts.io/reliably-insert-current-date-at-cursor-on-linux/
- Published: 2026-02-25T07:46:31.000Z
- Updated: 2026-02-25T07:46:31.000Z
- Author: Curiositry
- Tags: 100DaysToOffload, Linux, Productivity, Python

Long, long ago, in a dotfiles directory far away, I had this snippet:

```bash
bindsym control+semicolon exec date '+%Y-%m-%d' | tr -d "\n" | xsel -i -b && xdotool sleep 0.5 key "ctrl+v"
```

Isn’t it a beauty?

But it worked, in i3 on X11.

I devoted 500 words to [bemoaning](https://www.autodidacts.io/switching-to-sway-wayland-from-i3-x11-ubuntu/#more-fun-with-segmentation-faults) how hard it was to port this over to Wayland + Sway. The section was titled *More Fun with Segmentation Faults,* and my “solution” involved building alpha-quality software from source, and accepting an 80/20 solution.

And then I migrated to a boring version of Linux: Xfce (and later Cinnamon) on Linux Mint. Even though I was on X again, for some reason my original snippet no longer worked 😭.

I ended up running [AutoKey](https://github.com/autokey/autokey?ref=autodidacts.io) 24/7 *just so I could have this snippet.* And it didn’t even work reliably.

*Further reading:* [*Save the Date*](https://www.autodidacts.io/save-the-date/)*.*

Paste didn’t work in my terminal emulator, and I spend most of my time in Helix text editor, in Fish Shell, running in a Tmux session, in Ghostty (I know, I insist on making things difficult for myself).

I set it to fill the clipboard with the current date so that I could paste it, but I often ended up having something important already *on* the clipboard when I ran the shortcut, and overwriting it.

So today I made a small improvement. It tries to input the date directly with send\_keys. But it also *temporarily* puts the date on the clipboard. Before it puts the date on the clipboard, it backs-up whatever was on the clipboard. Then, after one second has elapsed, it restores the clipboard to its original state.

So if I’m in Helix, I hit Ctrl+; Ctrl+Shift+V (which is only as many keystrokes as typing `2026-`, so we are saving ourselves five whole keypresses here! And that’s assuming I know what the date is in the first place, which I usually don’t.)

Otherwise, it’s Ctrl+; and done.

Here’s my current AutoKey script:

```python
import time
output = system.exec_command("date -I") # ISO 8601 YYYY-MM-DD format
oldtext = clipboard.get_clipboard() # backup what's on the clipboard
clipboard.fill_clipboard(output) # put date on clipboard
keyboard.send_keys("<ctrl>+V") # paste date
time.sleep(1) # give user chance to paste if send_keys failed
clipboard.fill_clipboard(oldtext) # restore previous clipboard content

```

It still isn’t perfect, but it’s almost good enough.