I often need characters that aren't printed on my keyboard, such as the em dash (U+2014). On Windows I used Alt+0151, but on Linux I currently have to open a character table and search for the symbol. Is there a convenient keyboard shortcut or shell-based method that can insert a Unicode character directly into the text field I'm using?
4 Answers
If you want custom shortcuts instead of memorizing Compose sequences, a text-expansion tool such as Espanso can replace short triggers with characters or longer snippets. You could define something like :emdash: to insert the em dash in applications that support the tool.
There are a few other options depending on your keyboard layout. Some layouts provide the em dash with an AltGr combination. You can also enter the Unicode code point directly in many Linux applications by pressing Ctrl+Shift+U, typing 2014, and pressing Enter. That inserts U+2014.
The Compose key is probably the most convenient option. Configure a key as Compose or Multi Key, then press Compose followed by three hyphens to produce an em dash. It’s also useful for many other characters because the sequences are fairly intuitive, such as Compose, e, apostrophe for é or Compose, =, slash for ≠.
Compose sequences are much easier to remember than numeric Alt codes, especially when you need accented letters, currency symbols, or mathematical characters.
Some desktop environments also provide a keyboard utility that lets you hold a key to choose related characters. The exact behavior depends on the desktop environment and keyboard layout, so it may be worth checking the input or keyboard settings.

Keep in mind that layouts can map similar-looking dashes differently. For example, one layout may provide the em dash U+2014 while another provides the horizontal bar U+2015.