The Brilliant Compose Key

A compose key in a Linux environment is a modifier key which allows you to execute sequences of characters to input a special character that isn't on your keyboard. Here are a few examples:

An easily searchable list of the common compose key sequences is available on this page. You may also view the default compose key sequences on your own system with cat /usr/share/X11/locale/en_US.UTF-8/Compose. On NixOS, this file is stored in a different location: cat "$(nix eval --raw nixpkgs#libX11.outPath)/share/X11/locale/en_US.UTF-8/Compose.

Keys in compose key sequences do not need to be held down simultaneously like they do in the keyboard shortcut for copying text, Ctrl + C. This allows for quickly inputting sequences.

How To Set Your Compose Key

The compose key is usually on by default, but if it isn't, here are some instructions on how to enable it in a few environments:

I set my compose key to Insert, but you should use whatever works best for you.

Custom Compose Key Sequences

We are now reaching the fun aspect of the compose key. You can make your own custom compose key sequences, and also edit the defaults. Create a configuration file with touch ~/.XCompose. Open the file with your editor.

Place this line at the top of your file:

# This line is very important; it ensures all the default sequences are imported so you don't lose them.
include "%L"

Now, let's make a custom sequence. I want "fumo" to be inputted when I execute the sequence 'Compose + F + M'.

<Multi_key> <F> <M> : "fumo"

Pretty simple! You can also do longer sequenecs; F and M are two keys, but you can do more. Exempli gratia:

<Multi_key> <C> <R> <9> : "Cirno"

You can overwrite default key sequences in this file as well, as your custom sequences hold priority over the ones imported by include "%L".

If you are not certain about what to put in between the brackets (<>), then use wev (or xev on X11). For example, I'm not sure what to use for the tilde key, ~. I'll run wev in my terminal and press the tilde key a few times. The name of the key will be printed under the keysym field. Now I know that the name to use for the tilde key is asciitilde:

<Multi_key> <asciitilde> <M> <F> : "Good morning, Mr. Fool~!"

Conclusion

The compose key, to me, is like Neovim keybindings. It takes a short period of time to get used to, but once you do, you won't do that thing that I'm sure everyone does where you Google the name of a key you need and copy paste it. It's a useful feature that is often overlooked and rarely used to its maximum potential, so I write this in the hope that more people will learn about and use it. Cheers!