In this post, we'll show how to add a custom keyboard shortcut to paste predefined text in Linux Mint. We are going to use a package called - xdotool.

If you like to check how to add shortcut for pasting dates: Linux Mint - Add Hotkey to Paste/Insert Dates

Step 1: Install Xdotool

First we need to make sure that xdotool is installed on our system. If not we can add it by:

sudo apt install xdotool

Xdotool is included by default in repositories of Ubuntu and Linux Mint.

Step 2: Add Custom Keyboard Shortcut

Next step shows how to add a custom shortcut in Linux Mint:

  • Visit the Main Menu
  • Preferences
  • Search for Keyboard
  • Open Shortcuts
  • Navigate to Custom Shortcuts
  • Add custom shortcut - in the bottom left
  • Enter:
    • Name - Paste Custom Text
    • Command - example bash -c "sleep .1 && xdotool type \"$(date +'%Y-%m-%d')\""
  • Click to Keyboard bindings - unassigned
  • Select the keyword combination for this shortcut - after pressing the combination you will see a change from unassigned to your combination.

If the combination is used you will see a warning message that you are going to override the combination.


Step 3: Build the xdotool command for pasting simple text

Finally we need to build a command which is going to paste predefined text each time when a keyboard key is pressed. In this example we are interested in pasting simple text which makes the command simpler:

bash -c "sleep .2 && xdotool type 'Linux Mint'"

The command above will paste the text: Linux Mint - each time the key is pressed.

Step 4: Build the xdotool command for pasting new lines

If you like to get new lines pasted by xdotool you will need a simple trick. Let say that you like to paste:

Kind Regards!

You can achieve it by using: xdotool key KP_Enter to chain the text commands. The example below paste the text above:

bash -c "sleep .2 && xdotool type 'Softhints,' && xdotool key KP_Enter && xdotool key KP_Enter &&  xdotool type 'Kind Regards!'"

What if you like to have special symbols like `: Then the single quote guarantee that syntax is correct:

bash -c "sleep .2 && xdotool type '```python' && xdotool key KP_Enter && xdotool key KP_Enter &&  xdotool type '```'"

The command above will paste anywhere:




In this post, we looked at a general use case of using package xdotool - typing text. We also looked at using the tool for pasting text with new lines.

This is quite useful for automating repetitive text writing for word, mails etc.