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
The table below lists the available specifiers and predicates, along with examples of their usage:
|Working Directory||The absolute path of the current working directory when the user invokes the script|
|Contents Of Directory||The file contents of the current working directory, separated by newlines.|
|Git Remote||The remote URL associated with ||https://github.com/withfig/autocomplete.git|
|Git Root Directory||The absolute path of the folder containing the |
|Current Branch||The current branch name if the user is inside of a git repo, otherwise an empty string.|
|Contains||Evaluates to |
|Equals||Evaluates to |
|Starts with||Evaluates to |
|Ends with||Evaluates to |
|Matches||Evaluates to |
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.