A fast, keyboard-driven CLI tool with a Terminal User Interface (TUI) that routes clipboard content to pre-configured scripts. Perfect for quickly processing URLs, text snippets, or any clipboard content with custom commands.
- Fast TUI: Navigate scripts with arrow keys or fuzzy search
- Flexible Configuration: YAML-based script configuration with multiline support
- Cross-Platform: Works on Linux (X11/Wayland) and macOS
- Safe Execution: Proper shell escaping and timeout protection
- Dry-Run Mode: Preview commands before execution
- XDG Compliant: Follows XDG Base Directory specification
Go 1.24.0 or later
Platform-specific clipboard utilities:
-
Linux (X11): Install
xcliporxsel# Debian/Ubuntu sudo apt install xclip # Fedora sudo dnf install xclip # Arch sudo pacman -S xclip
-
Linux (Wayland): Install
wl-clipboard# Debian/Ubuntu sudo apt install wl-clipboard # Fedora sudo dnf install wl-clipboard # Arch sudo pacman -S wl-clipboard
-
macOS: No additional dependencies (uses built-in
pbpaste)
git clone <repository-url>
cd cliprouter
go build -o cliprouter
sudo mv cliprouter /usr/local/bin/-
Run the application (it will create a default config on first run):
cliprouter
-
Edit the configuration file:
# Linux nano ~/.config/cliprouter/config.yaml # macOS nano ~/Library/Application\ Support/cliprouter/config.yaml
-
Copy some text to your clipboard
-
Run cliprouter again and select your script!
The configuration file is a YAML file located at:
- Linux:
~/.config/cliprouter/config.yaml(or$XDG_CONFIG_HOME/cliprouter/config.yaml) - macOS:
~/Library/Application Support/cliprouter/config.yaml
scripts:
- name: Script Name
command: command to execute ${CLIP}- Maximum 10 scripts allowed
${CLIP}placeholder is replaced with clipboard content- Multiline commands are supported
scripts:
# Simple command
- name: Read It Later
command: readitlater ${CLIP}
# Command with arguments
- name: Bookmark URL
command: bookmark --path ~/bookmarks.yaml --input ${CLIP}
# Multiline script
- name: Process URL
command: |
#!/bin/bash
echo "Processing: ${CLIP}"
curl -X POST https://api.example.com/process \
-d "url=${CLIP}"
# Save to file with timestamp
- name: Save to Notes
command: |
echo "$(date): ${CLIP}" >> ~/notes/$(date +%Y-%m-%d).txt# Run with default config
cliprouter
# Use custom config file
cliprouter --config /path/to/config.yaml
# Enable verbose logging
cliprouter -v
# Preview command without executing
cliprouter --dry-run
# Custom timeout (default: 30 seconds)
cliprouter --timeout 60- ↑/↓ or k/j: Navigate scripts
- Type: Fuzzy search scripts
- Enter: Execute selected script
- Backspace: Remove search character
- ESC: Quit without executing
--config <path>: Specify custom configuration file-v,--verbose: Enable verbose logging to stderr--dry-run: Show command without executing--timeout <seconds>: Script execution timeout (default: 30)-h,--help: Show help message
Logs are stored at:
- Linux:
~/.local/share/cliprouter/cliprouter.log(or$XDG_DATA_HOME/cliprouter/cliprouter.log) - macOS:
~/Library/Application Support/cliprouter/cliprouter.log
Use -v flag to also output logs to stderr.
scripts:
- name: Pocket
command: pocket-cli add ${CLIP}scripts:
- name: Format JSON
command: echo ${CLIP} | jq .
- name: Format Go Code
command: |
echo ${CLIP} | gofmtscripts:
- name: Daily Note
command: |
echo "${CLIP}" >> ~/notes/$(date +%Y-%m-%d).txt
- name: Inbox
command: |
echo "- [ ] ${CLIP}" >> ~/inbox.mdscripts:
- name: Archive URL
command: waybackmachine ${CLIP}
- name: Take Screenshot
command: screenshot-url ${CLIP}Error: "Failed to read clipboard"
Solution: Install the appropriate clipboard utility:
- X11:
xcliporxsel - Wayland:
wl-clipboard
Error: "Clipboard is empty"
Solution: Copy some text before running cliprouter.
Error: "Failed to parse YAML"
Solution:
- Check YAML syntax (proper indentation, no tabs)
- Ensure each script has both
nameandcommandfields - Maximum 10 scripts allowed
Error: "Script execution timed out"
Solution: Increase timeout with --timeout flag:
cliprouter --timeout 60Check logs for details:
# Linux
tail -f ~/.local/share/cliprouter/cliprouter.log
# macOS
tail -f ~/Library/Application\ Support/cliprouter/cliprouter.logRun with verbose mode:
cliprouter -vTest command with dry-run:
cliprouter --dry-run# Run all tests
go test ./...
# Run tests for specific package
go test -v ./internal/config
# Run with coverage
go test -cover ./...# Format code
go fmt ./...
# Vet code
go vet ./...
# Run linter (if golangci-lint is installed)
golangci-lint run- Clipboard content is properly escaped before execution to prevent command injection
- Scripts execute with timeout protection (default 30 seconds)
- Configuration limited to maximum 10 scripts to prevent resource exhaustion
- Always review scripts in your configuration before executing
[Add your license here]
[Add contribution guidelines here]