Page Body

Get TextExpander Functionality on GNU/Linux With AutoKey

If you work with text and find yourself needing to continually use the same text or phrases, you may have come to appreciate the efficiency gains reaped from tools like TextExpander. Unfortunately, TextExpander does not make a GNU/Linux client, and has also moved their business to a subscription model, which some users are not comfortable with (1, 2).

If you are a GNU/Linux user and want to replicate TextExpander's functionality on your system, AutoKey can help you.

Note: If you are not familiar with the GNU/Linux command line interface, review the Conventions page before proceeding.


AutoKey is a desktop automation tool. Essentially, it is a Graphical User Interface (GUI) to run Python 3 scripts, with a focus on Macro and keypress functionality.

The AutoKey Wiki does a good job of explaining how the application can be useful:

There are certain things you type over and over; your address, your company name or your custom signature. AutoKey's abbreviations can automatically expand a few characters into any of your commonly used text blocks. For programmers, AutoKey's text insertion features can let you easily insert code tags, dividers, etc. at the cursor position.

If you use database, CAD/CAM, engineering or scientific software that require complex key combinations, AutoKey can be configured to send commands that will activate those features with a single keystroke.

Instead of just inserting text, a script can be used to manipulate several different running programs, transfer text between them, start and close them as well as send keyboard and mouse input to them.

AutoKey works across all applications. Any phrase, script or abbreviation can be used in multiple applications. This means you do not have to configure all the different applications that you use--you can do it once in AutoKey and it works for all your applications.

AutoKey is very useful if you write or edit business documents, novels, documentation, articles, web blogs, programs or fill out a lot of forms.


AutoKey key is an X Window System application. At present, AutoKey will not fully work on GNU/Linux systems that default to using Wayland.

You can find out if you are using the X Window System or Wayland by running the following command:


If you are using GNOME as your Desktop Environment, you can switch your system to using the X Window System at the login screen by selecting the Gear icon and choosing the Xorg option (Xorg is the open source version of the X Window System used in GNU/Linux).

Most likely, AutoKey is in your distribution's repository.

On Debian, you can install AutoKey with the following command:

# apt install autokey-gtk

On Fedora, use this command, instead:

# dnf install autokey-gtk


A good way to see how AutoKey works is through examples. One helpful way to use applications that enable text expansion is to create custom Markdown shortcuts. This is beneficial because you will only need to use a single set of triggers that you create that can work across applications, instead of remembering separate keyboard shortcuts for each application you use that supports Markdown.

Open the AutoKey GUI by pressing Super+k.

Bold Markdown Text Via an Abbreviation

First, make a new folder for your Markdown shortcuts.

In the AutoKey GUI, select the My Phrases folder and select New > Subfolder. Call the subfolder Markdown. Next, create a phrase for Markdown bold text. Select New > Phrase and name it Bold. In the text box that says Enter phrase contents, enter **<cursor>**. The <cursor> macro will insert the keyboard cursor inside the asterisks after you trigger this phrase.

There are various ways to trigger a phrase. For this example, use an Abbreviation. Next to Abbreviation, select Set. Check off Trigger immediately (don't require a trigger character). Next, select Add, enter mbb, and press Enter. Select OK and then enter Ctrl+s to save your changes.

Now, open an application on your system where you can add text and enter mbb. You should see something like this:

Bold Text

You can easily use this phrase to set up comparable Markdown phrases by right-clicking Bold and selecting Clone Item. Then, set an appropriate name, abbreviation, and change the phrase contents to match the appropriate syntax for that Markdown shortcut.

Your abbreviations for Markdown shortcuts should be easy to remember, but if you want an additional layer of convenience, set a Hotkey trigger for your Markdown folder. First, select the Markdown folder, and next to Hotkey, select Set. Next, select Press to Set, press the F8 key, and then select Control. Select OK and save your changes.

Now, you can press Ctrl+F8 anywhere on your system to get a navigable menu of your Markdown shortcuts.

Styling text in Markdown is relatively straightforward. Markdown links allow for more complicated situations that can showcase AutoKey's advanced functions. Next, we will create a phrase for a Markdown link.

You can create an AutoKey phrase to output the text you need for a Markdown link and place the cursor between the square brackets, similar to how you created a phrase for bold text (e.g., [<cursor>]()). This works fine if you want to manually enter every part of your Markdown link.

However, it does not work as well if you want to go back to previously written text and add a link. For example, it would be convenient if you could select some text, enter an AutoKey Hotkey, have the selected text become the Markdown link anchor text, and have a URL pulled from your system's clipboard to become the Markdown link.

In AutoKey, select New > Folder > Use Default and enter the name My Scripts. Select the My Scripts folder, then select New > Script. Name it get_selection. Under # Enter script code, add the following:

# Save selection to sel variable
sel = clipboard.get_selection()

# Set return value to sel variable value

Create another script in the My Scripts folder following the steps above, but call this new script get_clipboard. Add the following code to it:

# Save clipboard to cb variable
cb = clipboard.get_clipboard()

# Set return value to cb variable value

Next, select the Markdown folder you previously made and create a new phrase called Link (Selection). For the phrase contents, enter the following:

[<script name=get_selection args=>](<script name=get_clipboard args=>)

For the anchor text, <script name=get_selection args=> will return the result of your get_selection script. For the link, <script name=get_clipboard args=> will return the result of your get_clipboard script. We do not need to pass these functions any arguments, but, at present, an empty args= is required for this to work.

Set a Hotkey for the Link (Selection) phrase. Next to Hotkey, select Set. Then, select Press to Set and enter l. Next, select Control and Alt. Finally, select OK and press Ctrl+s to save your changes.

Now, when you need to turn written text into a Markdown link, copy the link to your system's clipboard, select the text you want to turn into a link, and enter Ctrl+Alt+l. You should see something like this:

Markdown Link Selection


The examples above are just a preview of what AutoKey is capable of. To learn more about the application and see more examples, the AutoKey Wiki is a good resource.

Specifically, you may want to focus on the following entries:

Enjoyed this post?

Subscribe to the feed for the latest updates.