Snippets
Save commands you use often, fill in variables, send them to a terminal, or run them on several servers.
Snippets
Snippets are saved commands. Send one to the current terminal in two keystrokes, or run it on several servers at once.
Create a snippet
On the Snippets page, click New snippet and give it a name, the command, and optionally a folder. A snippet can press Enter after itself, or only insert the text so you can check and edit it first.
In Blocks mode you can also hover a block and save it as a snippet.
Variables
Words like $SERVICE or $BRANCH in a snippet become fields you fill in before sending or
running it. Harbor remembers the last values. Common shell variables such as $HOME, $USER and
$PATH are left for the shell.
sudo systemctl restart $SERVICE && journalctl -u $SERVICE -n 50
Send a snippet to a terminal
Press Ctrl+Shift+S (macOS ⌘S), or choose Send snippet in the tab menu, and pick one. The command palette (Ctrl+Shift+K) also lists snippets.
Run on several hosts
- Open a snippet on the Snippets page.
- Under Run on, tick the hosts.
- Click Run.
Harbor runs the command on each host in turn over a background connection (no terminal needed), and stops at the first host where it fails, so a broken step doesn’t spread. Each host’s output and exit code are kept under Last run.
- Production hosts are called out before you run.
- Commands that a Block guardrail matches are refused on Production hosts.
- Each host must log in without asking (saved password, key or agent), and its host key must already be trusted.
- A command that runs longer than 5 minutes is stopped.