A command-line interface for PasteCTL, allowing developers to create, retrieve, and manage code snippets directly from the terminal.
PasteCTL CLI is a terminal-based client for the PasteCTL platform. It provides a fast and efficient way to share code snippets without leaving your development environment. The CLI integrates with your system's default editor and supports automatic language detection based on file extensions.
- Create Pastes: Create pastes from files or directly in your editor
- Automatic Language Detection: Detects language from file extensions
- Custom Expiry Times: Set paste expiration (10m, 1h, never, etc.)
- Retrieve Pastes: Fetch paste content with formatted output or raw text
- Update Pastes: Edit existing pastes in your preferred editor
- Configuration Management: Store API endpoint and frontend URL locally
- Cross-Platform: Works on Linux, macOS, and Windows
If you have Go 1.24.0 or higher installed:
go install github.com/Sumedhvats/pastectl@latestMake sure your $GOPATH/bin is in your PATH.
Download the appropriate binary for your platform from the releases page.
wget https://github.com/Sumedhvats/pastectl/releases/download/v0.1.1/pastectl_0.1.1_linux_amd64.tar.gz
tar -xvf pastectl_0.1.1_linux_amd64.tar.gz
sudo mv pastectl /usr/local/bin/Verify installation:
pastectl --helpwget https://github.com/Sumedhvats/pastectl/releases/download/v0.1.1/pastectl_0.1.1_darwin_amd64.tar.gz
tar -xvf pastectl_0.1.1_darwin_amd64.tar.gz
sudo mv pastectl /usr/local/bin/Verify installation:
pastectl --help- Download
pastectl_0.1.1_windows_amd64.zipfrom the releases page - Extract the archive
- Move
pastectl.exeto a directory in yourPATH(e.g.,C:\Windows\System32)
Verify installation in PowerShell:
pastectl.exe --helpPasteCTL CLI stores configuration in ~/.config/pastectl/config.yaml.
Configure the backend API URL:
pastectl config set backend_url https://api.paste.sumedh.appConfigure the frontend URL (for generating shareable links):
pastectl config set frontend_url https://paste.sumedh.app/pasteThe CLI comes with the following defaults:
- backend_url:
https://api.paste.sumedh.app - frontend_url:
https://paste.sumedh.app/paste
Configuration is automatically loaded on each command. To modify settings, use the config set command.
Open your system's default editor to create a paste:
pastectl createThe CLI will use the editor specified in your $EDITOR environment variable (defaults to vim on Unix/Linux/macOS, notepad on Windows).
Create a paste from an existing file:
pastectl create --file /path/to/file.goLanguage is automatically detected from the file extension.
Specify language and expiry time:
pastectl create --file script.py --language python --expire 1hExpiry options:
10m- 10 minutes1h- 1 hour24h- 24 hoursnever- No expiration (default)
Get paste with metadata:
pastectl get <paste-id>Output example:
--- Paste Details ---
ID: abc123
Language: go
Created: 2025-10-03 10:21:05
--- Content ---
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Get only the paste content (useful for piping):
pastectl get <paste-id> --rawExample usage with output redirection:
pastectl get abc123 --raw > downloaded.goEdit an existing paste in your editor:
pastectl update <paste-id>The CLI will:
- Fetch the current paste content
- Open it in your editor
- Update the paste with your changes
pastectl config set <key> <value>Available keys:
backend_url: API endpoint URLfrontend_url: Frontend base URL for shareable links
Example:
pastectl config set backend_url http://localhost:8080The CLI automatically detects the following languages from file extensions:
| Extension | Language |
|---|---|
.js |
javascript |
.py |
python |
.go |
go |
.java |
java |
.c |
c |
.cpp |
cpp |
.json |
json |
.md |
markdown |
.txt |
plain |
For other file types or editor-created pastes, you can manually specify the language using the --language flag.
PasteCTL respects your system's $EDITOR environment variable. To set your preferred editor:
Add to your shell configuration file (~/.bashrc, ~/.zshrc, etc.):
export EDITOR=nano # or vim, emacs, code, etc.$env:EDITOR = "notepad"Common editor options:
vim- Vim text editornano- Nano text editoremacs- Emacs editorcode- Visual Studio Code (usecode --wait)notepad- Windows Notepad
Create and share a code snippet:
# Create from file
pastectl create --file main.go --expire 24h
# Output:
# Creating paste...
# Paste created successfully!
# Link: https://paste.sumedh.app/paste/abc123Download and save a paste:
pastectl get abc123 --raw > downloaded.goEdit an existing paste:
pastectl update abc123Use a self-hosted PasteCTL instance:
pastectl config set backend_url http://localhost:8080
pastectl config set frontend_url http://localhost:3000/paste
pastectl create --file script.shThe CLI communicates with the PasteCTL backend via REST API:
- POST
/api/pastes- Create paste - GET
/api/pastes/:id- Get paste with metadata - GET
/api/pastes/:id/raw- Get raw paste content - PUT
/api/pastes/:id- Update paste
pastectl/
├── cmd/
│ ├── config.go # Configuration management
│ ├── create.go # Create paste command
│ ├── get.go # Retrieve paste command
│ ├── update.go # Update paste command
│ └── root.go # Root command setup
├── internal/
│ ├── api/ # API client
│ ├── config/ # Configuration handling
│ └── editor/ # Editor integration
├── main.go
└── go.mod
- cobra: CLI framework
- viper: Configuration management
- Go 1.24.0+: Required Go version
Clone the repository and build:
git clone https://github.com/Sumedhvats/pastectl.git
cd pastectl
go build -o pastectlInstall locally:
go install- PasteCTL Web - Full-stack web application with Next.js frontend and Go backend
If you see the error:
backend_url is not set. Please use 'pastectl config set backend_url <url>'
Configure the backend URL:
pastectl config set backend_url https://api.paste.sumedh.appIf your editor is not opening, set the EDITOR environment variable:
export EDITOR=vim # or your preferred editorIf you get a permission error when running the binary:
chmod +x pastectlFor issues, questions, or contributions, please visit the GitHub Issues page.
Made with ❤️ by Sumedh