A set of command-line utilities for reliable file handling through the system clipboard in Linux.
Key Feature: automatic filename preservation when copying and restoring it when pasting - no manual specification required!
| Utility | Purpose |
|---|---|
cf |
Copy File - copy file to clipboard |
pf |
Paste File - paste from clipboard to file with original name |
- β Automatic detection of binary files (images, PDFs, archives)
- β Binary data encoding in base64 for reliable transfer
- β Original filename preservation in metadata
- β Tab-completion for filenames in Zsh
- β Protection against accidental file overwrites
- β
Support for outputting clipboard content to terminal (
pf -)
# 1. Installation
git clone https://github.com/psqlmaster/clipboard-tools.git && \
cd clipboard-tools && \
chmod +x ./install.sh && \
sudo ./install.shcf document.pdf # Copy file to clipboard
pf # Paste as document.pdf
pf report.txt # Paste under different name
pf - | grep "error" # Output clipboard content to terminalcf ~/Downloads/screenshot.png
# β Binary file 'screenshot.png' encoded and copied
pf
# β Binary data saved to 'screenshot.png'cf ~/.ssh/id_rsa.pub
pf public_key.txt
# β Text saved to 'public_key.txt'pf -f existing_file.pdfpf - | head -20| Component | Purpose | Installation (Debian/Ubuntu) |
|---|---|---|
xclip |
Clipboard operations | sudo apt install xclip |
base64 |
Binary data encoding | included in coreutils |
file |
File type detection | pre-installed |
clipboard-tools/
βββ bin/ # executable wrappers
βββ lib/ # main logic
βββ share/zsh/vendor-completions/ # Zsh completions
βββ install.sh # installer
βββ README.md # documentation
βββ LICENSE # license# Installation (requires sudo)
sudo ./install.sh
# Check dependencies without installation
./install.sh --check
# Removal
sudo ./install.sh --uninstall- Zsh completions: After installation, run once:
autoload -Uz compinit && compinit-
Metadata: Information about the last copied file is stored in
~/.cache/clipboard-meta -
Safety: Binary files are always encoded in base64 - no risk of data corruption
BSD 3-Clause License - see license file
Designed for professionals who value efficiency and reliability in daily terminal work.