Snippets
Save the commands you run often and run them in a terminal or on many hosts in one click.
- Save commands and notes in folders
- Run them in one or more terminals, or straight on a set of hosts
- Variables for the host and your own inputs
- Encrypted secrets you can use as {{NAME}} in a command
- Run a snippet each time you connect to a host
- Share snippets with users or roles
- Import and export as JSON
- A snippets panel beside any SSH terminal
- A dashboard card to run host snippets or copy any snippet
Snippets are commands you save so you don't type them again: a restart, a log tail, a long diagnostic one-liner. Run them in a terminal, in several terminals at once, or straight on a set of hosts with no terminal open.
Make one
Open Snippets from the sidebar and add one with a name and the command. Put snippets in folders and drag them into the order you want.
A snippet can also be a Note: text that is pasted into the terminal without running, like a config block.
Variables
Snippets can fill in parts of the command when they run:
| Variable | Becomes |
|---|---|
$HOST | The host's address. |
$USER | The SSH username. |
$PORT | The SSH port. |
$NAME | The host's name in Termix. |
${INPUT_1:Label} | Something you type in before it runs. Label is the question you are asked. |
journalctl -u ${INPUT_1:Service} --since "${INPUT_2:Since}" -n 200
When a snippet has inputs, Termix asks for them and shows a preview before running.
Secrets
Keep keys and passwords out of your snippets. Open the snippet settings, add a secret under Secrets, then use it
in any command as {{NAME}}:
SOPS_AGE_KEY={{SOPS_AGE_KEY}} sops -d secrets.enc.yaml
Secrets are stored encrypted on the server, belong to you only and are never shown again after you save them. They are not synced to the desktop app. When a snippet runs, Termix fills in your own value, so a shared snippet uses the secret of whoever runs it. Every use is written to the audit log with the names, never the values.
A run on hosts fills the secret on the server and hides the value in the output it shows you. A run in a terminal types the value into the terminal, so the shell and its history can see it there. If a secret is missing, the snippet does not run.
Run one
- In a terminal: Click the snippet to send it to the terminal you are in. With several terminals selected, it goes to all of them.
- Beside a terminal: Open the Snippets panel from the edge of an SSH terminal or its tab menu. Clicking a snippet runs it in that terminal. Turn the panel off for a host in its Snippets settings.
- From the dashboard: Add the Snippets card in edit mode. It runs snippets with target hosts and copies the rest.
- On hosts: Set Target hosts on the snippet and use Run on target hosts. It runs over SSH on each one, without a terminal, and shows each result.
- From a key: Bind a snippet to a key in Settings, Keybindings.
- From the command palette: Search for it by name.
Turn on Confirm before running in your settings to be asked first.
A snippet run on hosts has no terminal, so sudo cannot ask for a password. Turn on Fill sudo password in your settings and Termix answers the prompt with the host's sudo password, or its SSH password when no sudo password is set.
On connect
Set a Startup Snippet on a host and it runs in the terminal every time you connect. A snippet that asks for inputs is skipped.
Quick actions
Quick Actions on a host are snippet buttons in that host's Host Metrics toolbar, for one click jobs.
Share
Share a snippet or a whole folder with users or roles. They can run it but not change it. Handy for a team's standard commands.
Import and export
The Snippets panel has Export and Import. The file is JSON:
{
"snippets": [
{
"name": "Restart nginx",
"content": "sudo systemctl restart nginx",
"description": "Restart the web server",
"folder": "Web",
"order": 0
}
],
"folders": [{ "name": "Web", "color": "#3b82f6", "icon": "folder" }]
}
name and content are required. When importing, pick whether to overwrite snippets with the same name and folder or skip them.
With other plugins
- Automations can run a snippet as a step.
- Fleets can run a snippet on every host in a fleet.
- AI Assistant can read and propose snippets.
Permissions
| Permission | What it allows |
|---|---|
snippets.view | See your own and shared snippets. |
snippets.create, snippets.edit, snippets.delete | Change them. |
snippets.share | Share them with users or roles. |
Environment variables
This plugin reads some environment variables on the Termix server. See the reference for the list.