Skip to content
Gerald Nunn edited this page Aug 14, 2016 · 16 revisions

Introduction

Terminix supports the concept of triggers, these are regular expressions defined by the user that when matched against text output by the terminal trigger an action. A trigger consists of a regular expression, the action to execute and a parameter string. Depending on the action, the parameter can not be used at all, a single string or a semi-colon delimited list of variables.

The result of the regular expression can be referenced as tokens in the parameter, Terminix will substitute the tokens in the parameter prior to executing the action. The token $0 refers to the complete regular expression match. If groups were defined in the regular expression, the tokens $1, $2, $3, etc refer to the individual group captures.

Supported Actions

The following actions are supported by Terminix:

Action Description
Update State This action updates the state that Terminix maintains about the terminal in terms of things like what directory or hostname is currently active in the terminal. The variables username, hostname and directory can be used to update the state respectively, these represent . See further below for an example of how to use this.
Execute Command This action executes the command provided in the parameter field.
Send Notification Sends a notification to the desktop environment. Two variables are supported by this action, title and body.
Update Title Updates the terminal title using the parameter field, it sets the override title specified in Layout Options.

Options

Terminix has an option to limit the number of lines that are checked for triggers, this is intended to improve performance on slower hardware. Every time a change happens in the terminal, this is reported to Terminix as a block of text. This block might consist of just a single character when the user is typing, or it might consist of several thousand lines when outputting a large text file via cat.

In the later scenario, we may generally not be too interested in checking for triggers in all lines of text. When this option is active, Terminix will only check the lines changed from the end of the text. So for example, if a block of text consisting of 20,000 lines of text was received but the option limit was active at 256, only the last 256 lines would be checked.

Examples

Here are some examples to help you use this feature:

Regular Express Action Parameter Description
^[(?P.)@(?P[-a-zA-Z0-9]) Update State username=$1;hostname=$2 Parses the username and hostname from a Linux prompt command that uses the following format: [username@hostname directory]$

How It Works

To get the most of out of this feature, it's important to understand how this works under the hood.

Terminix