square-codeSnippets

This page explains how to create, organize, and run snippets in Termius, including executing them on multiple hosts, setting startup snippets, and more.

Overview

In Termius, a snippet is a labeled shell script that you can save and run on different hosts without retyping it. Think of them as a cloud-synced library of your most-used or proven scripts/commands.

Snippets are stored in Vaults, synced across devices, and available to your team when you share the vault with a paid subscription. If you have a team, every member can contribute to the snippets library, making teamwork easier.

With snippets, you can:

  • Run the same command on multiple hosts

  • Run a startup snippet each time you connect to a host

  • Paste or run commands from the terminal side panel

  • Run saved commands from Autocomplete

  • Organize snippets with snippet packages

  • Share approved commands with your team

Create a snippet

On the Desktop, you can create a snippet either from the dedicated Snippets screen or from the side panel in the terminal. You can also use the AI to generate a snippet from your description.

From the Snippets screen

  1. Open the Vault tab, then open the Snippets screen

  2. Click New Snippet

  3. In the Action description field, describe what the snippet does. Enter the command in the Script field. Termius saves the snippet automatically


From the terminal side panel

  1. Open the side panel with Ctrl/Cmd + .

  2. Open the Snippets tab brackets-curly

  3. Click New Snippet

  4. In the Action description field, describe what the snippet does. Enter the command in the Script field

  5. Click Save


Generate with AI

  1. Open the New Snippet editor from the Snippets screen or the terminal

  2. In the Action description field, describe what the command should do in plain language

  3. Click the magic wand button

  4. Termius generates the snippet and inserts it into the Script field

Run snippets

To run a snippet from the terminal side panel:

  1. Open the side panel with Ctrl/Cmd + .

  2. Open the Snippets tab brackets-curly

  3. Hover over the snippet, then click PASTE or RUN:

    1. Paste inserts the snippet into the terminal without running it

    2. Run executes the snippet in the active terminal. You can also double-click the snippet

Execute a snippet on multiple hosts

Snippets can be executed on multiple hosts at the same time. Use this for updates, health checks, and config changes.

You can save a default set of target hosts for a snippet. The next time you run it from the Snippets screen, Termius preselects those hosts.

Running a snippet from the Snippets screen creates new connections to the selected hosts.

To run a snippet in existing sessions instead, use the terminal side panel.

To execute a snippet on multiple hosts from the Snippets screen:

  1. Open the Vault tab, then open the Snippets screen

  2. Double-click the snippet, or click the pen icon to edit it

  3. Select the target hosts

  4. Click Run

  5. Termius creates a workspace with the selected hosts

    1. The connection flow may ask for input if some host credentials are not saved

    2. After the hosts connect, Termius runs the snippet

    3. To stop execution, close a host tab or close the workspace tab

Click Save targets to store the selected hosts in the snippet. The next time you run it from the Snippets screen, those hosts are preselected.

Set up startup snippets

A startup snippet is a command that runs automatically every time you connect to a host.

Use it to open a directory, activate a virtual environment, run checks, or attach to an existing tmux session.

To enable a startup snippet for a host:

  1. Open the Host Details screen

  2. Scroll down to the Startup Command field and choose the snippet

  3. Save the host on mobile. On desktop, Termius saves it automatically

Organize snippets with packages

Snippets can be organized into packages. They work like folders. Create a package for a project, host category, or task type, then move related snippets into it.

Create a snippet package

To create a snippet package on the desktop:

  1. Open the Vault tab, then open the Snippets screen

  2. Click the chevron next to New Snippet, then click New snippet package

  3. Enter the package name in the Label field. Termius saves the package automatically

Move snippets into packages

To add a snippet to a package:

  • Open the Edit Snippet screen and select the package

  • Or, on the Snippets screen, select several snippets and drag them into a package

Share snippets within your team

Snippets are stored in vaults and follow the same access model as other vault content. Shared snippets sync automatically and are available to every team member with access to that vault.

To move snippets between vaults:

1

Open the Vault tab, then open the Snippets screen

2

Right-click the snippet, then choose an action:

  • Copy to: will create a copy of the selected snippet in the target vault

  • Move to: will transfer the snippet to the target vault

3

Select the target vault, then choose where to store credentials

You can also open the Edit Snippet screen and choose the vault there.

Delete snippets

If you no longer need a snippet, you can delete it from the Snippets screen.

circle-exclamation

To delete a snippet:

  1. Open the Vault tab, then open the Snippets screen

  2. Delete the snippet in one of these ways:

    • Right-click the snippet, then click Remove, or

    • Open the Edit Snippet screen, click the three-dots menu, then click Remove

Pro tips

Meaningful names

Use clear snippet names to make them easier to find with Autocomplete. Start typing and select the right suggestion.

Snippet variables

Termius does not support variables in the snippet editor yet. You can use the export command in a startup snippet to define environment variables for other snippets. You can also set environment variables in the Host Edit screen.

Last updated

Was this helpful?