Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often need to print the current date in lots of different programs. Right now, I always type it per hand which is error prone. I'm using KDE 4.8, and it has customisable keyboard shortcuts. For example, it is possible to create keyboard shortcuts that print out a predefined string. But is it somehow possible to print out the output of some executable to the keyboard?

share|improve this question
up vote 3 down vote accepted

I don't use KDE (I use Gnome), but this may help:

You'll need a program called xte from the xautomation package.

Create a bash script with this in it:

xte "str `date +%D`"

Save it and make it executable.

Create a keyboard shortcut in KDE that launches your script.

Now all you have to do is type your keyboard shortcut in any program and it will type out the date for you!

EDIT: If you have trouble getting this to work (like I had), try adding a short delay before the script runs xte:

sleep 0.3
xte "str `date +%D`"
share|improve this answer
Works perfectly, in some applications even without the sleep! Thanks! – Turion May 28 '12 at 16:14
Glad to be of help. – Isaac May 28 '12 at 23:07
I was searching for the same thing so thanks. It seems that the sleep in my case is needed because of the shortcut itself, i.e. I use a shortcut that contains Control which implies that when the date is "typed in" by the script, Control is pressed down and so the actuall keystrokes that are sent to X are Control+<first letter of the date>, etc... – Silverrocker Oct 10 '12 at 19:07
Interesting theory, I'll bet you're right. I also used the Ctrl key in my shortcut, so that was probably my problem too. – Isaac Oct 11 '12 at 14:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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