There are lots of websites which only allow signing in with email address and password and I am tired of typing a long email address. I don't want my browser to remember my email. Can I assign a keyboard shortcut to print this email address so that every time I press the key I get my email address on current text field?

I am using Ubuntu 14.04 and I have very little knowledge about Ubuntu. I'm not talking about snippets. Just a defined text to paste when the key is pressed.


To paste a single string into a textfield

  1. install both xdotool and xclip:

    sudo apt-get install xdotool xclip
  2. Add the following command to a shortcut key:

    /bin/bash -c "sleep 0.5 && printf 'youremail@server.com' | xclip -selection clipboard && xdotool key Control_L+v"

    Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command above to a key combination of your choice.

Now when enter the cursor in a textfield and choose your shortcut, it will type your email address.

  • 1
    Out of interest, why is the sleep 0.5 necessary? I noticed that it does not work without this. Sep 21 '16 at 9:35
  • 2
    @Exeleration-G If I remember well (it is a while ago) it is to make sure the shortcut keypress does not interfere with the simulated keypress by xdotool. Sep 21 '16 at 10:17
  • 3
    xdotool type --clearmodifiers 'youremail@server.com' Jan 23 '18 at 13:26
  • @Jacob Vlijm I tried your method, but got disable for the shortcut no matter which key combinations I tried.
    – fixit7
    Jul 13 '18 at 14:52
  • sleep duration can be customised. Lower will leave you less time to release your key combination but the text will come sooner.
    – zatiranyk
    Feb 21 at 21:39

Tested on Ubuntu 20.04. Similar to Jacob’s solution. Here, we will paste the text hello ♥ using the middle mouse click clipboard.

We won’t paste the text at the "| cursor" as using Ctrl+V but directly under the mouse cursor like when using the middle mouse click. You may replace xsel with xclip.

  1. Install xdotool and xsel:
sudo apt install xdotool xsel
  1. Add the following command to a shortcut key:
/bin/bash -c 'echo -n "hello ♥" | xsel && xdotool click 2'

Note: We use the clipboard of the middle mouse, so expect it to be erased along with the current selection when using your custom shortcut.

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.