4

I need a time-stamp that is inserted with a hot key, like F5 in old notepad. Format should be:

hh:mm dd.mm.yyyy.

p.s. Dot in the end of the year is grammatically correct in Serbian language, so it is not a mistake.

1
  • I think it is not possible without patching the source code. But you can get this stamp in terminal by date +%H:%M\ %d.%m.%Y.. You can set an alias for this command to enter it fast.
    – Pilot6
    Aug 15, 2015 at 14:31

1 Answer 1

2
  1. Install the package xdotool via, we need the command xdotool

    sudo apt-get install xdotool
    
  2. Create a small script

    #!/bin/bash
    sleep 0.1
    xdotool type $(date +"%H:%M")' '$(date +"%d.%m.%Y.")
    
    • If the output does not looks something like

      17:31 15.08.2015.
      

      use

      #!/bin/bash
      sleep 0.1
      xdotool type $(date +"%H")':'$(date +"%M")' '$(date +"%d")'.'$(date +"%m")'.'$(date +"%Y")'.'
      
    • If the time is not fully inserted after pressing the shortcut, increment the parameter for sleep, eg 0.5, in the script

  3. Make it executable

    chmod +x your_script
    
  4. Assign a keyboard shortcut for the script, eg Super+F5 or some other shortcut that is not used.

    enter image description here

10
  • Did you test it in nano? It has another binding for F5. But it can be undone in .nanorc
    – Pilot6
    Aug 15, 2015 at 14:48
  • @Pilot6 No :) only in gedit and in a terminal … But Super+F5 should work.
    – A.B.
    Aug 15, 2015 at 14:58
  • Super+F5 will open an app from launcher. F5 works but shows 18^01 15.08.2015.
    – Pilot6
    Aug 15, 2015 at 15:00
  • @Pilot6 18^01? why the ^? o_O
    – A.B.
    Aug 15, 2015 at 15:05
  • @Pilot6 Can you test it with xdotool type $(date +"%H")':'$(date +"%M")' '$(date +"%d")'.'$(date +"%m")'.'$(date +"%Y.") please?
    – A.B.
    Aug 15, 2015 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.