Skip to main content

Creating & Managing Snippets

This guide covers everything you need to know about creating, editing, duplicating, and managing your snippet library.

Creating Your First Snippet

Method 1: From Snippets Tab

Step 1: Open Snippets

1. Click "Snippets" in sidebar
2. Click green "NEW SNIPPET" button
3. Or press Ctrl+Shift+N (Cmd+Shift+N on Mac)

Step 2: Fill in Details

┌──────────────────────────────────────────┐
│ New Snippet │
├──────────────────────────────────────────┤
│ Name: * │
│ [Docker Container Restart ] │
│ │
│ Category: │
│ [Docker Commands ▼] │
│ │
│ Description: │
│ [Restart a Docker container by name] │
│ │
│ Command: * │
│ ┌──────────────────────────────────────┐ │
│ │ docker restart {{container_name}} │ │
│ │ │ │
│ └──────────────────────────────────────┘ │
│ │
│ Variables detected: container_name │
│ │
│ [Cancel] [Create] │
└──────────────────────────────────────────┘

Step 3: Save

  • Click "Create" button
  • Snippet appears in list
  • Ready to use!

Method 2: From Terminal Tab

Save command from terminal history:

1. Open Terminal tab
2. Run a command
3. Right-click in terminal
4. Select "Save as Snippet"
5. Edit name and details
6. Save

Perfect for capturing commands you just used!

Method 3: From Template Library

Use pre-made templates:

1. Click "NEW SNIPPET" dropdown
2. Select "From Templates"
3. Browse template categories
4. Click "Use Template"
5. Customize for your needs
6. Save

Method 4: Import from File

Import existing snippet collections:

1. Click "Import" button
2. Select .json file
3. Review snippets
4. Choose which to import
5. Assign categories
6. Complete import

Snippet Fields Explained

Name (Required)

Purpose: Identify the snippet

Best Practices:

✓ "Docker: Container Restart"
✓ "Git: Create Feature Branch"
✓ "Database: MySQL Backup"
✓ "Server: Update Packages"

✗ "snippet1"
✗ "command"
✗ "docker"

Tips:

  • Use prefix for category (Docker:, Git:, etc.)
  • Start with verb (Restart, Create, Backup)
  • Be specific
  • Keep under 50 characters

Command (Required)

Purpose: The actual command(s) to execute

Single Command:

docker restart {{container_name}}

Multiple Commands:

cd {{project_path}}
git pull origin {{branch}}
npm install
npm run build

Complex Script:

#!/bin/bash

# Variables
BACKUP_DIR="/backups"
DATE=$(date +%Y%m%d_%H%M%S)

# Create backup
mysqldump -u {{user}} -p{{password}} {{database}} \
> $BACKUP_DIR/{{database}}_$DATE.sql

# Compress
gzip $BACKUP_DIR/{{database}}_$DATE.sql

# Cleanup old backups
find $BACKUP_DIR -name "*.sql.gz" -mtime +7 -delete

echo "Backup complete: {{database}}_$DATE.sql.gz"

Category (Optional)

Purpose: Organize snippets into groups

Common Categories:

📁 Docker Commands
📁 Git Operations
📁 Database Management
📁 System Administration
📁 Deployment
📁 Monitoring
📁 Backup & Restore
📁 File Operations
📁 Network Tools

Creating New Category:

1. In category dropdown
2. Click "Create New Category"
3. Enter name
4. Choose color/icon (optional)
5. Save

Purpose: Document what the snippet does

Good Description:

Restarts a specific Docker container by name.
Use when container needs clean restart after
configuration changes. Safe for production use.

Requirements:
- Docker installed
- Container must exist
- User must have Docker permissions

Include:

  • What it does
  • When to use it
  • Requirements
  • Warnings (if any)
  • Expected output

Variables

Purpose: Make snippets dynamic

Auto-Detection: Variables are automatically detected from {{}} syntax:

docker exec -it {{container_name}} {{command}}
↓ ↓
Variable detected Variable detected

Variable Names:

✓ {{container_name}}  - Descriptive
✓ {{user}} - Clear
✓ {{backup_file}} - Specific
✓ {{environment}} - Meaningful

✗ {{var1}} - Unclear
✗ {{x}} - Too short
✗ {{a}} - Meaningless

Default Values: You can provide defaults when executing:

container_name: my-app (default)
command: /bin/bash (default)

Editing Snippets

Edit Snippet Details

1. Find snippet in list
2. Click three-dots menu (⋯)
3. Select "Edit"
4. Make changes
5. Click "Save Changes"

Or:

  • Right-click snippet
  • Select "Edit"

Or:

  • Select snippet
  • Press E key

Editable Fields

All fields can be edited:

  • ✏️ Name
  • ✏️ Command
  • ✏️ Category
  • ✏️ Description
  • ✏️ Variables (auto-detected)

Quick Edit

Edit without opening dialog:

1. Click snippet name
2. Type new name
3. Press Enter

Bulk Edit

Edit multiple snippets:

1. Select snippets (Ctrl+Click)
2. Right-click selection
3. Choose "Bulk Edit"
4. Change category/tags
5. Apply to all

Duplicating Snippets

Create variations of existing snippets:

Why Duplicate?

Use Case 1: Different Environments

Original: Deploy to Staging
Duplicate: Deploy to Production
(change server, credentials)

Use Case 2: Similar Commands

Original: Docker Container Start
Duplicate: Docker Container Stop
(change command verb)

Use Case 3: Variations

Original: MySQL Backup (all databases)
Duplicate: MySQL Backup (single database)
(modify command)

How to Duplicate

Method 1: Duplicate Button

1. Find snippet
2. Click three-dots menu (⋯)
3. Select "Duplicate"
4. New snippet created with "(copy)" suffix
5. Edit the duplicate

Method 2: Keyboard Shortcut

1. Select snippet
2. Press Ctrl+D (Cmd+D on Mac)
3. Edit duplicate

Method 3: Right-Click Menu

1. Right-click snippet
2. Select "Duplicate"
3. Confirm

After Duplication

Original: "Docker Restart"
Duplicate: "Docker Restart (copy)"

Rename to: "Docker Restart Production"
Update command with production values

Organizing Snippets

Using Categories

Create Category:

1. Click "Categories" tab
2. Click "New Category"
3. Enter details:
- Name: Docker Commands
- Color: Blue
- Icon: 🐳 (optional)
- Description: All Docker-related commands
4. Save

Assign to Category:

1. Edit snippet
2. Select category from dropdown
3. Save

View by Category:

1. Filter dropdown
2. Select category
3. Only that category shown

Search & Filter

Search by Name:

Type in search box:
"docker" → Shows all Docker snippets
"backup" → Shows all backup snippets

Search by Content:

Searches command content too:
"mysqldump" → Shows all MySQL backup snippets

Filter by Category:

1. Category dropdown
2. Select category
3. View filtered results

Clear Filters:

Click "Clear Filters" button
Or: Ctrl+K (Cmd+K on Mac)

Sorting

Sort Options:

  • Name (A-Z)
  • Name (Z-A)
  • Most Used
  • Recently Used
  • Recently Created
  • Recently Modified

Change Sort:

1. Click sort dropdown
2. Select sort method
3. List reorders

Favorites/Pinning

Mark most-used snippets:

1. Click star icon on snippet
2. Snippet pinned to top
3. Quick access

Keyboard Shortcut:

Select snippet → Press S (star)

Deleting Snippets

Delete Single Snippet

Method 1: Menu

1. Click three-dots menu (⋯)
2. Select "Delete"
3. Confirm deletion

Method 2: Keyboard

1. Select snippet
2. Press Delete/Backspace key
3. Confirm

Method 3: Right-Click

1. Right-click snippet
2. Select "Delete"
3. Confirm

Delete Multiple Snippets

Bulk Delete:

1. Select snippets (Ctrl+Click)
2. Press Delete key
3. Confirm deletion of X snippets

Delete by Category:

1. Right-click category
2. Select "Delete All Snippets"
3. Confirm (careful!)

Soft Delete vs Permanent Delete

Soft Delete (Default):

  • Snippet hidden but not removed
  • Can be restored
  • Useful for cleanup
  • Sync-safe

Restore Deleted:

1. Click "Show Deleted"
2. Find snippet
3. Click "Restore"
4. Snippet back in list

Permanent Delete:

1. Show deleted snippets
2. Right-click deleted snippet
3. Select "Permanently Delete"
4. Confirm (cannot be undone!)

Snippet Templates

Using Built-in Templates

Browse Templates:

1. Click "NEW SNIPPET" dropdown
2. Select "From Templates"
3. Browse categories:
- Docker Commands
- Git Operations
- Database Tasks
- System Admin
- Web Development

Use Template:

1. Click template
2. Preview command
3. Click "Use This Template"
4. Customize variables
5. Save as snippet

Creating Your Own Templates

Export as Template:

1. Create perfect snippet
2. Right-click snippet
3. Select "Export as Template"
4. Add to template library
5. Share with team

Template Collections

Import Collection:

1. Download .json template file
2. Click "Import Templates"
3. Select file
4. Review templates
5. Import all or selected

Example Collections Available:

  • DevOps Essentials (50 snippets)
  • Docker Management (30 snippets)
  • Database Admin (40 snippets)
  • Git Workflows (25 snippets)

Import & Export

Export Snippets

Export All:

1. Click "Export" button
2. Choose format:
- JSON (recommended)
- Plain text
- Markdown
3. Select location
4. Save file

Export Category:

1. Right-click category
2. Select "Export Category"
3. Choose format
4. Save file

Export Selected:

1. Select snippets (Ctrl+Click)
2. Right-click selection
3. Select "Export Selected"
4. Save file

Export Format (JSON):

{
"version": "1.0",
"exported": "2024-01-15T10:30:00Z",
"snippets": [
{
"name": "Docker Restart",
"command": "docker restart {{container}}",
"category": "Docker",
"description": "Restart container",
"variables": ["container"]
}
]
}

Import Snippets

Import from File:

1. Click "Import" button
2. Select .json file
3. Preview snippets
4. Handle conflicts:
- Skip existing
- Overwrite
- Keep both
5. Complete import

Merge Strategy:

┌────────────────────────────────────────┐
│ Import Conflicts Found │
├────────────────────────────────────────┤
│ 3 snippets already exist: │
│ │
│ ● Docker Restart │
│ [Skip] [Overwrite] [Keep Both] │
│ │
│ ● Git Pull Rebase │
│ [Skip] [Overwrite] [Keep Both] │
│ │
│ ● MySQL Backup │
│ [Skip] [Overwrite] [Keep Both] │
│ │
│ Apply to all: [Skip] [Overwrite] [Both]│
└────────────────────────────────────────┘

Import from URL:

1. Click "Import from URL"
2. Paste snippet collection URL
3. Preview and import

Share Snippets

Share Single Snippet:

1. Right-click snippet
2. Select "Share"
3. Choose method:
- Copy to clipboard
- Generate share link
- Export as file
- Send to email

Share with Team:

1. Export category/collection
2. Upload to shared location
3. Team members import
4. Everyone uses same snippets

Snippet Statistics

Usage Tracking

View Stats:

Snippet: Docker Restart
├─ Total Uses: 47
├─ Last Used: 2 hours ago
├─ Created: Jan 15, 2024
├─ Modified: Feb 1, 2024
└─ Success Rate: 98%

Sort by Usage:

1. Sort dropdown
2. Select "Most Used"
3. See your top snippets

Usage Insights:

📊 Your Top Snippets:
1. Docker Restart (47 uses)
2. Git Pull & Rebase (35 uses)
3. npm Build (28 uses)
4. MySQL Backup (22 uses)
5. Server Health Check (18 uses)

Analytics

Weekly Report:

This Week:
- 127 snippet executions
- 15 new snippets created
- 8 snippets modified
- Top category: Docker (45%)

Advanced Features

Snippet Variables

Detailed coverage in Variables Guide

Quick Reference:

# Simple variable
docker restart {{container}}

# Multiple variables
scp {{file}} {{user}}@{{host}}:{{path}}

# With defaults
git checkout {{branch=main}}

Conditional Execution

Add Prompts:

#!/bin/bash
echo "This will delete production data!"
read -p "Type 'yes' to confirm: " confirm
if [ "$confirm" != "yes" ]; then
echo "Cancelled"
exit 1
fi

# Proceed with command...

Error Handling

Check Command Success:

docker restart {{container}}

if [ $? -eq 0 ]; then
echo "✓ Container restarted successfully"
else
echo "✗ Failed to restart container"
exit 1
fi

Try-Catch Pattern:

{
cd {{project_path}} &&
git pull origin {{branch}} &&
npm install &&
npm run build
} || {
echo "Build failed!"
exit 1
}

Environment Variables

Use System Variables:

# Current user
ssh $USER@{{host}}

# Home directory
cd $HOME/{{project}}

# Path
export PATH=$PATH:{{custom_path}}

Tips & Best Practices

1. Name Consistently

Use Pattern:

[Category]: [Action] [Target]

Examples:
Docker: Container Restart
Git: Branch Create
Database: Backup MySQL
Server: Update Packages

2. Add Rich Descriptions

Template:

What: [Brief explanation]
When: [Use cases]
Requirements: [Prerequisites]
Output: [Expected result]
Notes: [Important info]

Example:

What: Creates full MySQL database backup
When: Before major updates, daily backups, migration
Requirements: mysqldump installed, credentials configured
Output: Compressed .sql.gz file in /backups
Notes: Runs in background, ~5 min for 10GB database

3. Test Before Saving

1. Write command
2. Test manually in terminal
3. Verify it works
4. Save as snippet
5. Test snippet execution
6. Update if needed

4. Use Categories Effectively

Organize by:

  • Purpose (Deployment, Backup, Monitoring)
  • Technology (Docker, Git, Database)
  • Frequency (Daily, Weekly, Emergency)
  • Environment (Dev, Staging, Production)

5. Regular Maintenance

Monthly Review:

□ Delete unused snippets
□ Update outdated commands
□ Consolidate duplicates
□ Add new common commands
□ Update descriptions
□ Re-categorize if needed

6. Backup Regularly

1. Export all snippets monthly
2. Save to cloud storage
3. Version the export file
4. Keep 3 months history

7. Share with Team

Build Team Library:

1. Create shared categories
2. Document standards
3. Regular sync meetings
4. Collect feedback
5. Iterate and improve

Troubleshooting

Snippet Won't Save

Issue: Create button disabled

Solutions:

  • Ensure name is filled
  • Ensure command is filled
  • Check for invalid characters
  • Verify variable syntax

Variables Not Detected

Issue: Variables don't show up

Cause: Wrong syntax

Fix:

✗ {container}        - Single braces
✗ {{container - Missing closing
✗ {{container name}} - Space in name
✓ {{container_name}} - Correct!

Execution Fails

Issue: Snippet fails when executed

Check:

  • Variable values are correct
  • Paths exist
  • Permissions are sufficient
  • Dependencies installed
  • Network connectivity

Debug:

1. Copy command
2. Paste in terminal
3. Run manually
4. Check error message
5. Fix issue
6. Update snippet

Import Errors

Issue: Import fails or incomplete

Solutions:

  • Verify JSON format
  • Check file encoding (UTF-8)
  • Ensure valid syntax
  • Update app to latest version
  • Try importing fewer snippets

Next Steps