dev:manual:automations:aliases

Create an alias

An alias matches a command you type and replaces it with another command or script. This example makes k goblin send kill goblin.

Build the alias

  1. Open a profile, connected or offline.
  2. Open Automations and choose Create alias.
  3. Set Name to kill-shortcut.
  4. Set Pattern to ^k (.+)$.
  5. In Test against a command, enter k goblin. The tester should report a match.
  6. Leave Behavior on Send as text.
  7. In Script, enter kill $1.
  8. Choose Create alias.

A new text alias with a pattern, matching test command, and kill $1 action

Return to the session, type k goblin, and press Enter. Smudgy sends kill goblin.

What the pattern means

The Pattern field uses a regular expression.

  • ^ means the start of the command.
  • k matches those literal characters, including the space.
  • (.+) captures one or more characters.
  • $ means the end of the command.

The action's $1 is replaced by the first captured group. Named groups also work: ^k (?<target>.+)$ can send kill $target. Use $$ when the action needs a literal dollar sign.

Anchoring the pattern matters. A pattern of only k could also match unrelated input containing that letter.

Send more than one command

Use the command separator in a text action:

stand;get sword;wield sword

These commands re-enter the normal outgoing pipeline in order, so another alias can match one of them. Keep chains short enough to understand when a later alias changes the result.

Use JavaScript only when needed

Switch Behavior to JavaScript for conditions, state, or client-only effects. The body runs as user code and can use the smudgy scripting API. For reusable code or more than a small body, move the work into a module.

If the alias does not run

Check the editor's tester, the enabled switch, and the folder's enabled state. Then check whether an earlier alias replaced the command first. See Organize and troubleshoot automations.