Snippets
Snippets are saved commands. They live in the Command Library, which you open from the bookmark icon in the home screen’s top bar or from Command Library in the desktop sidebar. The library has two tabs: Library for single commands and Runbooks for multi-step procedures.
Snippets are part of Free, with no limit on how many you save.
The built-in library
Section titled “The built-in library”The library ships with 187 ready-made commands, tagged by topic: system information, processes, systemd, packages, users, disks, logs, networking, security, SSL/TLS, cron, Git, backups, performance, Docker, Kubernetes, Nginx and Apache, MySQL, PostgreSQL, Redis, MongoDB and the AWS, GCP and Azure command-line tools. They appear in the same list as your own snippets and work the same way.
Create a snippet
Section titled “Create a snippet”- In the Library tab, tap New Snippet.
- Enter a name and the command. Both are required.
- Optionally add a description, tags and a folder under Details. Tags you already use are suggested as you type.
- Tap Save.
The editor’s menu has Convert to runbook, which turns the snippet into a runbook whose first step is its command. A runbook converts back with Convert to single command.
Long-press a snippet (or right-click it on desktop) for Edit, Add to favorites, Duplicate, Move to folder and Delete.
Variables
Section titled “Variables”Write a placeholder as {{name}} in the command and it becomes a prompt when the snippet runs:
sudo systemctl restart {{service}}docker logs --tail {{lines}} {{container}}The editor detects placeholders as you type and lists them under Variables. For each one you can set a Label (shown on the prompt), a Default value, Hint text and Secret, which masks the input. Removing a placeholder from the command removes its variable. Names may contain letters, digits and underscores.
Values are shell-escaped when they are substituted. A value made only of letters, digits and @%_+=:,./- is inserted as typed; anything else is wrapped in single quotes, so a value containing spaces, quotes, ; or $(...) stays one argument and can’t start a second command. Write placeholders without quotes around them. If you do put one inside quotes, PocketCmd escapes the value for that quoting instead of adding more.
A placeholder that has no variable, such as Docker’s {{.Names}}, is left as it is.
Run a snippet on a server
Section titled “Run a snippet on a server”Tap a snippet in the library. Fill in its variables, pick the server under Run on server, and tap Run.
The command runs in its own shell on an SSH connection to the server, separate from any terminal you have open, and its output and exit status appear in the runner:
- The runner turns off shell history before anything is typed, so commands with resolved secrets are not written to the server’s history file.
- Values of Secret variables are masked wherever the command is displayed. Copying such a command goes through the secure clipboard.
- A command that prints nothing for 5 minutes is interrupted with Ctrl-C and marked TIMED OUT. A command that keeps printing is never cut off.
- Stop ends a run at any time by closing the shell.
The runner needs a POSIX shell on the server. If the login shell is fish, csh or tcsh, the runner switches to bash or sh for the run.
On Free, servers beyond the Free limit are listed last and grayed out in the server picker; tapping one explains why it is locked.
Insert a snippet into a terminal
Section titled “Insert a snippet into a terminal”In a terminal session, tap the bookmark key on the keyboard toolbar to open the snippet palette above the keyboard. Search or filter by tag and pick a snippet. If it has variables, fill them in and tap Insert Command.
The resolved command is typed at the prompt without pressing Enter, so you can check or edit it first. Picking a runbook from the palette opens the runbook runner instead.
Organize and find snippets
Section titled “Organize and find snippets”The filter chips under the search field show All, Favorites, Recent and one chip per tag. Without a search or filter, the list shows favorites first, then recently used snippets, then the rest by name.
Search matches the name, tags, command and description, and ranks matches in that order.
Snippets can be filed into folders. A folder opens and closes with a tap; long-press it to rename or delete it. Deleting a folder keeps its snippets and moves them to the top level. The app has no button for creating folders: they arrive with an imported backup or from another synced device.
Snippets and runbooks
Section titled “Snippets and runbooks”| Snippet | Runbook | |
|---|---|---|
| Commands | One | An ordered list of steps |
| Variables | Yes | Yes, collected from every step |
| On a non-zero exit | The run shows the failure | The run stops, unless the step has Continue on error |
| Output check | No | Optional expected output per step |
| Pause between steps | No | Optional per step |