Snippets & Custom Commands
Save reusable CLI snippets you paste into the terminal, and build right-click custom actions in NetStacks for terminal commands, API calls, and scripts.
Overview
NetStacks gives you two distinct, complementary ways to avoid re-typing the same CLI:
- Snippets — named, reusable command strings you keep in a library. Open the snippets menu, pick one, and its text is pasted into the active terminal so you can review and press Enter.
- Custom Commands (also called Custom Actions) — entries you add to the terminal’s right-click context menu. A custom command can run a terminal command, call an API Quick Action, or run a script, and can appear either always or only when you right-click a detected value such as an IP address or MAC.
The two features are deliberately different: snippets are about pasting reusable text on demand, while custom commands extend the right-click menu with one-click actions tied to what you clicked.
A snippet is simply a name and a single command string. There is no {{variable}} prompting, categories, or per-line delays. If you need a placeholder that gets substituted from the terminal, use a dynamic custom command instead (see below), which supports a single {value} placeholder.
Snippets
Snippets are stored as a simple list of name / command pairs. Each snippet is either global (available in every session) or session-scoped (bound to a single session). Global snippets can also carry a shared flag so they can be offered to other users; if you did not create a shared snippet, it is shown as read-only.
Opening and using the snippets menu
- In the terminal status bar, click the Snippets button. (If you don’t see it, enable the Snippets status-bar item in Settings.)
- Type in the search box to filter by snippet name or command text.
- Click a snippet — its command text is pasted into the active terminal. Review it, then press Enter to run it. Selecting a snippet does not auto-execute, so it is safe to inspect before sending.
Managing snippets
Click Manage Snippets… at the bottom of the menu, or run the Snippets… command from the command palette, to open the Snippets tab in Settings. There you can:
- Click + New Snippet, give it a Name and a Command, and Save.
- Edit a snippet’s name or command inline.
- Delete a snippet (you’ll be asked to confirm).
Both fields are required — a snippet must have a non-empty name and a non-empty command before it can be saved.
A snippet holds one command string. For a sequence of commands, create one snippet per command, or paste the snippet and append the remaining commands manually. The text is pasted as-is, so what you save is exactly what lands in the terminal.
Snippet Examples
A snippet is just a name plus a command. Examples of useful entries:
Name: Check BGP Summary
Command: show ip bgp summary
Name: OSPF Neighbors
Command: show ip ospf neighbor
Name: Interface Errors
Command: show interfaces | include error|CRC|drops
Name: Save Running Config
Command: copy running-config startup-configSnippets are persisted through the local CRUD API at the /snippets endpoint. The stored shape for a snippet looks like this (fields such as id, sort_order, and created_at are assigned by the backend):
{
"id": "a1b2c3d4-...",
"session_id": null,
"name": "Check BGP Summary",
"command": "show ip bgp summary",
"sort_order": 0,
"shared": false,
"created_at": "2026-06-15T12:00:00Z"
}A session_id of null means the snippet is global; a non-null value scopes it to that session. When creating a snippet you only supply name, command, and optionally shared:
POST /snippets
Content-Type: application/json
{
"name": "Interface Errors",
"command": "show interfaces | include error|CRC|drops"
}Custom Commands (Right-Click Actions)
Custom commands add entries to the terminal’s right-click context menu. Manage them in Settings under the Custom Actions tab. Each action has a name, an action type, and a rule for when to show it.
Action types
- Terminal Command
- Sends a CLI command to the active session, for example
ping 8.8.8.8. - API Quick Action
- Invokes a previously defined API Quick Action. Only quick actions with exactly one variable are eligible; the detected value is passed into that single variable.
- Script
- Runs a saved script. Only scripts whose
main()takes zero or one parameter are eligible; with one parameter, the detected value is passed in as that argument.
When to show: static vs. on detection
- Always Show (static) — the action always appears in the right-click menu, regardless of what you clicked.
- On Detection (dynamic) — the action appears only when you right-click a value matching one or more selected detection types: IPv4, IPv6, MAC, Interface, VLAN, CIDR, ASN, or a Custom Regex. For terminal commands, use
{value}in the command as the placeholder for the detected text.
Each action also has an Enabled toggle. On macOS you can additionally surface an action in the Force Touch popover with Enable in Force Touch Menu.
In a dynamic terminal command, write {value} where the clicked text should go — for example show ip route {value}. Right-click an IP in the terminal and the action runs with that IP substituted in.
Custom Command Examples
Static terminal command
Always shown in the right-click menu; runs a fixed command.
Name: Ping Google DNS
Action Type: Terminal Command
Command: ping 8.8.8.8
When to Show: Always ShowDynamic terminal command (on detection)
Appears only when you right-click an IPv4 or CIDR value; the clicked value is substituted into {value}.
Name: Route Lookup
Action Type: Terminal Command
Command: show ip route {value}
When to Show: On Detection
Detection Types: IPv4, CIDRDetection types are stored as a JSON array in detection_types; a custom regex is encoded as regex:<pattern>. A static action stores detection_types: null. The persisted object is created via the /custom-commands CRUD endpoint:
POST /custom-commands
Content-Type: application/json
{
"name": "Route Lookup",
"command": "show ip route {value}",
"detection_types": "[\"ipv4\",\"cidr\"]",
"enabled": true,
"action_type": "terminal",
"quick_action_id": null,
"quick_action_variable": null,
"script_id": null,
"show_in_force_click": false
}API Quick Action bound to a detected value
Links the action to an API Quick Action that has exactly one variable. The clicked value is passed into quick_action_variable.
{
"name": "NetBox Lookup",
"command": "",
"action_type": "quick_action",
"quick_action_id": "qa-7f3e-...",
"quick_action_variable": "address",
"detection_types": "[\"ipv4\"]",
"enabled": true
}An API Quick Action must expose exactly one variable to be usable as a custom command, and a script’s main() must take zero or one parameter. If nothing is selectable, create or simplify the underlying quick action or script first.
Q&A
- Q: What is the difference between a snippet and a custom command?
- A: A snippet is reusable command text you pick from the snippets menu; selecting it pastes the text into the terminal for you to run. A custom command is an entry in the terminal’s right-click context menu that runs a terminal command, an API Quick Action, or a script — optionally only when you right-click a detected value.
- Q: Does selecting a snippet run it automatically?
- A: No. The snippet’s command is pasted into the active terminal so you can review it and press Enter yourself.
- Q: Can I use variables or prompts in a snippet?
- A: Snippets do not support variable prompting; they are plain text. For a substituted placeholder, use a dynamic custom command with
{value}, which is filled from the value you right-click in the terminal.
- Q: Are snippets shared across sessions or with my team?
- A: Global snippets (those with a null
session_id) are available in every session. A global snippet can also be markedsharedso it can be offered to other users; shared snippets you didn’t author are read-only to you. Session-scoped snippets only appear in their own session.
- Q: How do I make a right-click action appear only for IP addresses?
- A: Create a custom command, set When to Show to On Detection, and check the IPv4 (and/or IPv6, CIDR) detection type. Use
{value}in a terminal command to receive the clicked address.
- Q: Where are snippets and custom commands stored?
- A: Both are managed through simple CRUD APIs —
/snippetsand/custom-commands. In standalone mode they live on the local agent; in enterprise mode they are stored per user on the controller.
Troubleshooting
Snippets button is missing from the status bar
- Enable the Snippets status-bar item in Settings. The button only renders when the Snippets status item is turned on.
Can’t save a snippet
- Both Name and Command are required. The Save button stays disabled until both fields contain non-whitespace text.
A snippet appears read-only
- Shared snippets you did not author are read-only. Duplicate it into a new snippet of your own if you need to change it.
Dynamic custom command never appears
- Confirm the value you right-clicked actually matches a checked detection type (IPv4, MAC, Interface, etc.). If using a custom regex, verify the pattern matches the on-screen text.
- Check that the action is Enabled.
No quick actions or scripts available to select
- API Quick Actions must have exactly one variable, and scripts must have a
main()with zero or one parameter, to be eligible as a custom command. Adjust the underlying action or script first.
Related Features
- Terminal Overview — the terminal surface where snippets paste and custom actions appear in the right-click menu.
- Keyboard Shortcuts — faster ways to drive the terminal and command palette.
- Multi-Send (Broadcast) — send a pasted snippet to many sessions at once.
- Session Context — how detection works on terminal output for dynamic actions.
- Connecting — establish the sessions your snippets and actions run against.