A modern command-line snippet manager with Git synchronization, clipboard integration, and parameterized commands
Project description
pypet - Command Line Snippet Manager
pypet is a Python-based command-line snippet manager inspired by pet. It helps you organize and reuse command-line snippets efficiently, with a focus on simplicity and usability.
Features
- Store command snippets with descriptions and tags
- TOML-based storage (
~/.config/pypet/snippets.toml) - List and search your snippets with rich terminal output
- Interactive command execution with pre-execution editing
- Copy snippets to clipboard for easy pasting into other applications
- Git synchronization for backup and sharing across devices
- Parameterized snippets with default values
- Automatic backup and restore functionality
- Tag-based organization
- Modern Python implementation with type hints
- Comprehensive test coverage
Installation
PyPI (Recommended)
pip install pypet-cli
Development Installation
# Clone repository
git clone https://github.com/fabiandistler/pypet.git
cd pypet
# Install with uv (recommended)
uv pip install -e .
# Or with pip
pip install -e .
Requirements
- Python 3.10 or higher
- Git (for synchronization features)
Usage
Basic Commands
# List all snippets
pypet list
# Add a new snippet
pypet new "git commit -m" -d "Create a git commit" -t "git,version-control"
# Search snippets
pypet search "git"
# Execute a snippet (interactive if no ID provided)
pypet exec [snippet-id]
# Execute with editing
pypet exec [snippet-id] -e
# Copy a snippet to clipboard
pypet copy [snippet-id]
# Execute with copy to clipboard option
pypet exec [snippet-id] --copy
# Edit a snippet
pypet edit <snippet-id>
# Delete a snippet
pypet delete <snippet-id>
# Git synchronization
pypet sync init # Initialize Git repository
pypet sync status # Show sync status
pypet sync commit -m "message" # Commit changes
pypet sync pull # Pull from remote
pypet sync push # Push to remote
pypet sync sync # Full sync (commit + pull + push)
Parameterized Snippets
You can create snippets with customizable parameters:
# Create a snippet with parameters
pypet new "docker run -p {port}:80 -v {path}:/app -e NODE_ENV={env=development} {image}" \
-d "Run a Docker container with custom settings" \
-t "docker,container" \
-p "port:Host port to bind,path:Volume path,env=development:Node environment,image:Docker image name"
# Execute with parameter values
pypet exec <snippet-id> -P port=3000 -P path=$PWD -P image=node:18-alpine
# Or execute interactively (will prompt for parameter values)
pypet exec <snippet-id>
Parameters can have:
- Required values:
{name} - Default values:
{name=default} - Descriptions (shown when prompting)
Example TOML storage for a parameterized snippet:
[snippets.unique-id]
command = "docker run -p {port}:80 -v {path}:/app -e NODE_ENV={env=development} {image}"
description = "Run a Docker container with custom settings"
tags = ["docker", "container"]
created_at = "2025-06-17T10:00:00+00:00"
updated_at = "2025-06-17T10:00:00+00:00"
[snippets.unique-id.parameters.port]
name = "port"
description = "Host port to bind"
[snippets.unique-id.parameters.path]
name = "path"
description = "Volume path"
[snippets.unique-id.parameters.env]
name = "env"
default = "development"
description = "Node environment"
[snippets.unique-id.parameters.image]
name = "image"
description = "Docker image name"
Interactive Mode
When running pypet exec without a snippet ID, it enters interactive mode:
- Shows a table of all available snippets
- Lets you select a snippet by number
- Optionally allows editing the command before execution
- Asks for confirmation before running the command
Git Synchronization
pypet supports Git-based synchronization to backup and share your snippets across devices.
Setup
# Initialize Git repository for snippets
pypet sync init
# Initialize with remote repository
pypet sync init --remote https://github.com/username/pypet-snippets.git
Basic Operations
# Check sync status
pypet sync status
# Commit current changes
pypet sync commit -m "Added new Docker snippets"
# Pull changes from remote
pypet sync pull
# Push changes to remote
pypet sync push
# Full sync (commit + pull + push)
pypet sync sync
Backup Management
# List available backups
pypet sync backups
# Restore from backup
pypet sync restore snippets_backup_20250101_120000.toml
Workflow
- Initial Setup: Run
pypet sync initto create a Git repository - Add Remote: Use
--remoteoption or manually configure Git remote - Regular Sync: Use
pypet sync syncto keep snippets synchronized - Automatic Backups: Backups are created before pull operations
Development
This project uses uv for dependency management and pytest for testing.
-
Clone the repository:
git clone https://github.com/yourusername/pypet.git cd pypet
-
Set up the development environment:
uv venv source .venv/bin/activate uv pip install -e ".[dev]"
-
Run tests:
pytest
-
Try the CLI:
pypet --help
Storage Format
Snippets are stored in TOML format at ~/.config/pypet/snippets.toml:
[snippets.unique-id]
command = "git status"
description = "Check git status"
tags = ["git", "status"]
created_at = "2025-06-17T10:00:00+00:00"
updated_at = "2025-06-17T10:00:00+00:00"
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see the LICENSE file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypet_cli-0.1.0.tar.gz.
File metadata
- Download URL: pypet_cli-0.1.0.tar.gz
- Upload date:
- Size: 59.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac150e354a874a21a286a803c76c68693cacceca56bcce4a5456723fcc862842
|
|
| MD5 |
7e3d18966ac63a6209fad75cedd78b2b
|
|
| BLAKE2b-256 |
be18d888fa17b48f8fbfd0f4023c70e29cca62a134dd33ef1b720031481684b9
|
File details
Details for the file pypet_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pypet_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34fafa585c9cc4fba0b47019f9b8edffba90878550146036e13fa1da6071fb1e
|
|
| MD5 |
27bf43e874a24e031359c951b6f4419d
|
|
| BLAKE2b-256 |
3c5e6e38560a25c919344e8cee87f0854d275b4fd363b833360ddf34210f714e
|