Skip to content

Command Snippets

During daily operations, we frequently need to type complex and lengthy commands (like Docker cleanup or Kubernetes log fetching). The Snippets feature allows you to save these commands and inject them instantly on any server.

In Normal Mode, press S (uppercase) to summon the Snippet Picker overlay.

  • Press o to create a new snippet.
  • In the creation form, you can specify: a name, the long command you want to save, and tags for quick searching (e.g., docker, network).
  • Press / at any time to globally search your snippet library.

The most powerful aspect of Snippets is its support for dynamic variable substitution. You can write uppercase placeholders in your command using the format {{VAR_NAME}}.

For example:

Terminal window
docker logs -f --tail {{LINE_COUNT}} {{CONTAINER_NAME}}

When you select and attempt to execute this snippet from the picker, PhanTerm does not send the command immediately. Instead, it presents an elegant sequence of input prompts, asking you to provide specific values for LINE_COUNT and CONTAINER_NAME. After entering the values and pressing Enter, the fully constructed command is instantly executed in your current terminal.

All PhanTerm command snippets are stored in a structured YAML configuration file (snippets.yaml). This means you can entirely delegate the creation and management of your snippet library to an AI assistant!

You can simply copy the Prompt Instructions below, send them to your AI assistant, and replace your specific requirement in the final brackets:

You are an expert in server operations and the PhanTerm terminal.
Please write a set of PhanTerm-specific command snippets based on my requirements.
### Formatting Rules & Constraints
1. You must output valid YAML. The top-level structure must be `version: 1` and a `snippets:` list.
2. Only use the following fields: `name` (required), `command` (required), `description` (optional), `tags` (optional list of strings).
3. **Never** output a fabricated `variables:` field.
4. Variables must be declared by using uppercase placeholders directly within the `command` string, formatted as `{{VAR_NAME}}`. For example: `docker logs {{CONTAINER_NAME}} --tail {{LINES}}`.
5. `name` and `command` must be provided; `name` should be concise and indicate intent clearly.
### Example Reference
version: 1
snippets:
- name: Tail service logs
command: journalctl -u {{SERVICE}} -n {{LINES}} -f
description: Continuously track recent logs of a system service
tags:
- logs
- debug
### My Requirement Is:
[Replace this bracket with your specific needs, e.g., Please give me a set of snippets for cleaning K8s Evicted Pods and troubleshooting network issues]