Skip to content

BaseMax/go-clipboard-plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

go-clipboard-plus

An advanced clipboard manager and transformer for developers with cross-platform support, history tracking, text transformations, and custom scripting hooks.

Features

  • πŸ–₯️ Cross-platform: Works on Linux, macOS, and Windows
  • πŸ“‹ Clipboard Operations: Read from and write to system clipboard
  • πŸ“š History Tracking: Automatically tracks clipboard history (up to 100 entries)
  • πŸ”„ Text Transformations: Built-in transformations for common tasks
    • Format/minify JSON
    • Trim whitespace
    • Case conversions (upper, lower, title)
    • Base64 encode/decode
    • URL encode/decode
    • Reverse text
  • πŸ”§ Custom Hooks: Execute custom scripts on clipboard content
  • ⌨️ Clean CLI: Simple and intuitive command-line interface

Installation

Prerequisites

Linux: Install xclip or xsel

# Ubuntu/Debian
sudo apt-get install xclip

# Fedora
sudo dnf install xclip

# Arch Linux
sudo pacman -S xclip

macOS: No additional dependencies (uses built-in pbcopy/pbpaste)

Windows: No additional dependencies (uses PowerShell)

Build from source

git clone https://github.com/BaseMax/go-clipboard-plus.git
cd go-clipboard-plus
go build -o clipctl ./cmd/clipctl

Then move the clipctl binary to a directory in your PATH:

sudo mv clipctl /usr/local/bin/

Usage

Basic Commands

Copy to clipboard

# Copy text directly
clipctl copy "Hello World"

# Copy from stdin
echo "Hello World" | clipctl copy
cat file.txt | clipctl copy

Paste from clipboard

# Paste to stdout
clipctl paste

# Pipe to other commands
clipctl paste | grep "pattern"

View clipboard history

# Show last 10 entries (default)
clipctl history

# Show last N entries
clipctl history -n 5

# Show all entries
clipctl history -a

# Copy a specific history entry to clipboard
clipctl history -g 2

Clear history

clipctl clear

Transformations

Apply transformations to clipboard content:

# Format JSON
clipctl transform json

# Minify JSON
clipctl transform json-minify

# Trim whitespace
clipctl transform trim

# Convert to uppercase
clipctl transform upper

# Convert to lowercase
clipctl transform lower

# Title case
clipctl transform title

# Base64 encode
clipctl transform base64

# Base64 decode
clipctl transform base64d

# URL encode
clipctl transform url

# URL decode
clipctl transform urld

# Reverse text
clipctl transform reverse

Custom Hooks

Create custom script hooks to process clipboard content:

# Show hooks directory
clipctl hook --dir

# List available hooks
clipctl hook --list

# Execute a hook
clipctl hook my-script

Creating a Hook

  1. Create an executable script in the hooks directory:
mkdir -p ~/.config/go-clipboard-plus/hooks
  1. Create a script (e.g., uppercase.sh):
#!/bin/bash
tr '[:lower:]' '[:upper:]'
  1. Make it executable:
chmod +x ~/.config/go-clipboard-plus/hooks/uppercase.sh
  1. Use it:
clipctl hook uppercase.sh

Hooks receive clipboard content via stdin and should output the processed content to stdout.

Advanced Examples

# Copy file contents and format as JSON
cat data.json | clipctl copy
clipctl transform json

# Chain operations with paste
clipctl paste | jq . | clipctl copy

# Get history entry and encode to base64
clipctl history -g 0
clipctl transform base64

# Process clipboard with custom hook
clipctl paste | clipctl hook my-processor

Architecture

go-clipboard-plus/
β”œβ”€β”€ cmd/
β”‚   └── clipctl/          # CLI application
β”‚       └── main.go
β”œβ”€β”€ pkg/
β”‚   β”œβ”€β”€ clipboard/        # Cross-platform clipboard access
β”‚   β”‚   β”œβ”€β”€ clipboard.go  # Interface
β”‚   β”‚   β”œβ”€β”€ linux.go      # Linux implementation
β”‚   β”‚   β”œβ”€β”€ darwin.go     # macOS implementation
β”‚   β”‚   └── windows.go    # Windows implementation
β”‚   β”œβ”€β”€ history/          # History tracking
β”‚   β”‚   └── history.go
β”‚   β”œβ”€β”€ transform/        # Text transformations
β”‚   β”‚   └── transform.go
β”‚   └── hooks/            # Custom script hooks
β”‚       └── hooks.go
└── README.md

Configuration

Configuration files are stored in:

  • Linux/macOS: ~/.config/go-clipboard-plus/
  • Windows: %USERPROFILE%\.config\go-clipboard-plus\

Files

  • history.json: Clipboard history storage
  • hooks/: Directory for custom hook scripts

Development

Running Tests

# Run all tests
go test ./...

# Run tests for specific package
go test ./pkg/transform -v
go test ./pkg/history -v

# Run tests with coverage
go test -cover ./...

Building

# Build for current platform
go build -o clipctl ./cmd/clipctl

# Build for specific platform
GOOS=linux GOARCH=amd64 go build -o clipctl-linux ./cmd/clipctl
GOOS=darwin GOARCH=amd64 go build -o clipctl-mac ./cmd/clipctl
GOOS=windows GOARCH=amd64 go build -o clipctl.exe ./cmd/clipctl

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Author

Max Base

Acknowledgments

  • Uses OS-specific clipboard utilities for reliable clipboard access
  • Inspired by various clipboard manager tools

About

An advanced clipboard manager and transformer for developers with cross-platform support, history tracking, text transformations, and custom scripting hooks. An advanced clipboard manager and transformer for developers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors