SupportRules

Rules

Conditions that must be met for a script to be executed

Rules allows you to specify conditions that must be met in order for a script to be executed. This ensures that scripts are only run in the appropriate context, and can help prevent errors and unintended consequences.

Creating a Rule

To create a new rule, go to the "Rules" tab when editing a script.

A rule consists of a specifier and a predicate. The specifier is the subject of the rule, and can be one of several options such as the working directory or the contents of a directory. The predicate defines the condition that must be met by the specifier in order for the rule to evaluate to true.

The table below lists the available specifiers and predicates, along with examples of their usage:

Specifiers

SpecifierDescriptionExample
Working DirectoryThe absolute path of the current working directory when the user invokes the script/User/mschrage/projects/autocomplete
Contents Of DirectoryThe file contents of the current working directory, separated by newlines.hello.txt
Git RemoteThe remote URL associated with origin if the user is inside of a git repo, otherwise an empty string.https://github.com/withfig/autocomplete.git
Git Root DirectoryThe absolute path of the folder containing the .git directory if the user is inside of a git repo, otherwise an empty string./User/mschrage/projects/autocomplete
Current BranchThe current branch name if the user is inside of a git repo, otherwise an empty string.main

Predicate

OperationParameterDescription
Contains<string>Evaluates to true if the specifier contains <string>
Equals<string>Evaluates to true if the specifier equals <string>
Starts with<string>Evaluates to true if the specifier starts with <string>
Ends with<string>Evaluates to true if the specifier ends with <string>
Matches<regex>Evaluates to true if the specifier matches the <regex>

Combining Rules

Boolean logic can be used to combine multiple rules in order to create more complex and flexible matching criteria.

Rules in the same row are evaluated using the OR operator, so if any of the rules in a row are true, the entire row will evaluate to true. Rules in different rows are joined using the AND operator, so every row must evaluate to true in order for the script to be executed.