{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreifz5s6cc5mbeej46b6nrw2befleozrmp43x4nvj7j5efprfo6jhbi",
    "uri": "at://did:plc:fuaxi56ej27ymlesklypt3ar/app.bsky.feed.post/3mfo6ugluw2u2"
  },
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreicvjqfcyov5w75mjpdtvdi3k7fi27epohskv7twr7zy4hmi334rxu"
    },
    "mimeType": "image/png",
    "size": 290420
  },
  "description": "\n\n\n\n\nLong, long ago, in a dotfiles directory far away, I had this snippet:\n\n\nbindsym control+semicolon exec date '+%Y-%m-%d' | tr -d \"\\n\" | xsel -i -b && xdotool sleep 0.5 key \"ctrl+v\"\n\n\nIsn’t it a beauty?\n\n\nBut it worked, in i3 on X11.\n\n\nI devoted 500 words to bemoaning 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.\n\n\nAnd then I",
  "path": "/reliably-insert-current-date-at-cursor-on-linux/",
  "publishedAt": "2026-02-25T07:46:31.000Z",
  "site": "https://www.autodidacts.io",
  "tags": [
    "bemoaning",
    "AutoKey",
    "_Save the Date_"
  ],
  "textContent": "Long, long ago, in a dotfiles directory far away, I had this snippet:\n\n\n    bindsym control+semicolon exec date '+%Y-%m-%d' | tr -d \"\\n\" | xsel -i -b && xdotool sleep 0.5 key \"ctrl+v\"\n\nIsn’t it a beauty?\n\nBut it worked, in i3 on X11.\n\nI devoted 500 words to bemoaning 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.\n\nAnd 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 😭.\n\nI ended up running AutoKey 24/7 _just so I could have this snippet._ And it didn’t even work reliably.\n\n_Further reading:_ _Save the Date_ _._\n\nPaste 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).\n\nI 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.\n\nSo 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.\n\nSo 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.)\n\nOtherwise, it’s Ctrl+; and done.\n\nHere’s my current AutoKey script:\n\n\n    import time\n    output = system.exec_command(\"date -I\") # ISO 8601 YYYY-MM-DD format\n    oldtext = clipboard.get_clipboard() # backup what's on the clipboard\n    clipboard.fill_clipboard(output) # put date on clipboard\n    keyboard.send_keys(\"<ctrl>+V\") # paste date\n    time.sleep(1) # give user chance to paste if send_keys failed\n    clipboard.fill_clipboard(oldtext) # restore previous clipboard content\n\n\nIt still isn’t perfect, but it’s almost good enough.",
  "title": "It’s surprisingly hard to reliably paste the current date at the cursor on Linux",
  "updatedAt": "2026-02-25T07:46:31.000Z"
}