APC Australia

Expand text easily

Shashank Sharma is all for conservati­on of energy, so he’s mighty excited about Espanso, which helps him write more by typing less.

-

Whether we’re executing your favourite commands, frequently accessing certain directorie­s, websites, or signing off email messages, we do a lot of repetitive typing during the course of the day. A lot of this effort can be saved by using text expansion tools such as Espanso.

Espanso is an Italian word meaning ‘expand’ – and that’s precisely what the tool does. It lets you create a list of keywords or snippets which you can associate with longer words, expression­s or even sentences. Any time a configured keyword or snippet is encountere­d, Espanso automatica­lly replaces it with the text.

A versatile tool

Released under the GPLv3, this minimalist utility also supports just about all graphical applicatio­ns such as email clients, browsers and so on. It also has extensive support for the command line and can be used to execute custom scripts, expand keywords into frequently used code snippets, and more.

The project provides a Snap package for effortless installati­on, but there’s also a DEB package for Debian and Ubuntu and derivative distros. If you use Arch, you can install it using the AUR package. The documentat­ion on the project’s website lists all its dependenci­es such as libxtst6 , libxdo3 , xclip and libnotify-bin . You’ll find these in the software repositori­es for most distributi­ons. Once installed, you can then download the Espanso tarball and move the extracted script to a directory in your

$PATH :

$ wget -c https://github.com/ federico-terzi/espanso/releases/ latest/download/espanso-linux. tar.gz/

$ tar zxvf espanso-linux

$ mv espanso ~/.local/bin

Now all you need to do is launch Espanso with the espanso start

command. Espanso automatica­lly creates a configurat­ion file called default.yml in the ~/.config/ espanso/ directory.

You can edit the config file in any text editor of your choice, but running the espanso edit

command automatica­lly opens the config file in the default editor. Whenever you make changes to the config file, Espanso automatica­lly reloads the config file so that the changes can take effect. You can also manually restart Espanso with the espanso restart command.

Once you start Espanso, the utility continuall­y runs in the background waiting to catch trigger words so that they may be replaced. You may, however, want to occasional­ly disable Espanso so as to avoid expansion. By default, the Left-Alt key is configured to toggle the utility: double-press LeftAlt to disable Espanso if it’s running. You can then enable it by again pressing the Left-Alt key twice. If you wish to change this default toggle, add the following lines to your ~/.config/espanso/

default.yml file: toggle_key: LEFT_META

You can also use the Shift, Ctrl or Alt key, but remember to specify left or right with the toggle_key option if you want the option restricted to a single key. If you set toggle_key: CTRL for instance, you’ll be able to use both left and right Ctrl keys to toggle Espanso. Setting toggle_key: OFF in the config file completely disables the toggle key.

Triggers and matches

Espanso’s config file uses the YAML language, so you must make a point to use indentatio­n and other syntax peculiarit­ies when editing the file. If you haven’t already, scroll through the default.yml file at this point. You can run the command

espanso path to determine the path of the config file.

Creating rules for expanding text is quite straightfo­rward. You need to specify a trigger word and the text you wish to replace it with:

- trigger: “:be” replace: “///BEGIN CODE///” - trigger: “:en” replace: “///END CODE///”

Each trigger is preceded by a colon. This is only because of the project author’s familiarit­y with the Vim text editor; you can create a trigger with any other symbol if you find that more convenient:

- trigger: “!be” replace: “///BEGIN CODE///” Here, we’ve created a trigger for !be instead of :be as in the previous example. Espanso’s backend has the option of using an Inject or Clipboard method when replacing text. The third option, Auto, is available only for Linux users and is a combinatio­n of the others. The Clipboard option should be used only when you find that the expanded text is either missing characters, or otherwise is improperly implemente­d. For instance, if Espanso only expands the text partially, or deletes some other word from your text, you should specify the clipboard backend for that specific trigger:

- trigger: “:be” replace: “///BEGIN CODE///” force_clipboard: true

By default, Espanso places the cursor at the end of the expanded text. But you may occasional­ly want the cursor to be placed in between or anywhere else in the expanded text. You can specify the location of the cursor in the expanded text with $|$ . For instance, instead of using :be and :en triggers, we can create a single trigger:

- trigger: “:co” replace: “///BEGIN CODE///$|$/// END CODE///” force_clipboard: true

Here, we’ve used $|$ to specify the location of the cursor in the middle. You must similarly use \n to inform Espanso that you wish to create a new line for multi-line expansion.

Espanso boasts a wide variety of trigger matches and many different properties to make typing fun for you. For instance, the propogate_ case property can be used to retain the case of your trigger:

- trigger: “vis” replace: “visionary” propagate_case: true word: true

Now if you use vis , it will be automatica­lly expanded to ‘visionary’, but if you use Vis it will be expanded to ‘Visionary’ – and

VIS will be expanded to ‘VISIONARY’. You’ll notice that for this trigger, we didn’t use a : when specifying the trigger. Also note the

word: true option . This is used to ensure that Espanso only performs the expansion when the trigger is not followed by separators such as a comma or space, so that you can still type ‘visit’ without fear of expanding it.

Keeping track

Your config file will continue to grow with time, and can become unmanageab­le if you keep adding new triggers to it. An easy solution to this problem is to break different types of triggers into different files.

For instance, all the triggers that you wish to use for one type of work, such as email, can be stored in a separate file, while triggers for browsing the internet can be stored in another. You can give these files any name you like, but adhere to the YAML syntax of the default.yml file. Also, at the top of these files add the following: name: separatefi­le parent: default

The parent:default property informs Espanso that all the matches in the file should be merged with the default.yml config file. You can create as many config files as you like. Each new file should be placed in the ~/.config/ espanso/user directory.

All the triggers defined in the default.yml config file, and any other file which use the parent:default property, are deployed globally and available across all applicatio­ns. If you want certain triggers to be used only for certain applicatio­ns, you must create applicatio­n-centric config files. These files should also be stored in the ~/.config/espanso/ user directory. Refer to the documentat­ion to learn how to create this.

Due to space constraint­s, we haven’t been able to cover Espanso’s myriad abilities here, which can take a while to master or even understand.

Make sure to devote time to the documentat­ion, the official sub-Reddit and even the GitHub page.

“Any time a configured keyword or snippet is encountere­d, Espanso automatica­lly replaces it with the text.”

 ??  ?? Refer to the documentat­ion on the website to learn about different types of matches, how to efficientl­y organise config files, and more.
Refer to the documentat­ion on the website to learn about different types of matches, how to efficientl­y organise config files, and more.
 ??  ?? The command ‘espanso detect’ can be used to determine the Class, Executable path, or Title of any window.
The command ‘espanso detect’ can be used to determine the Class, Executable path, or Title of any window.

Newspapers in English

Newspapers from Australia