| Crates.io | pt-cli |
| lib.rs | pt-cli |
| version | 1.0.33 |
| created_at | 2025-11-18 17:57:24.010912+00 |
| updated_at | 2025-11-18 17:57:24.010912+00 |
| description | Production-hardened clipboard-to-file tool with smart version management |
| homepage | |
| repository | https://github.com/cumulus13/pt.git |
| max_upload_size | |
| id | 1938743 |
| size | 106,020 |
A robust command-line tool for managing clipboard content with intelligent file versioning, backup management, and recursive search capabilities.
# Clone repository
git clone https://github.com/cumulus13/pt.git
cd pt
# Build release binary
cargo build --release
# Binary will be at: target/release/pt
# Optional: Install to system
cargo install --path .
cargo install pt-cli
# Write clipboard to file
pt notes.txt
# Write with check mode (skip if identical)
pt notes.txt -c
# Write with comment
pt notes.txt -m "Initial draft"
# Append clipboard to file
pt append log.txt
pt append log.txt -m "New entry"
# List all backups
pt list notes.txt
# Restore from backup (interactive)
pt restore notes.txt
# Restore last backup
pt restore notes.txt --last
# Compare with backup using delta
pt diff notes.txt
pt diff notes.txt --last
# Show directory tree
pt tree
pt tree /path/to/dir
pt tree -e node_modules,.git
# Configuration
pt config init # Create sample config
pt config show # View current settings
pt config path # Show config location
# Version info
pt -V
pt --version-info
# Basic write
pt <filename> # Write clipboard to file
pt <filename> -c # Check mode (skip if identical)
pt <filename> -m "comment" # With comment
pt <filename> -c -m "comment" # Check mode with comment
pt append <filename> # Append clipboard
pt append <filename> -m "msg" # Append with comment
pt list <filename> # List all backups
pt restore <filename> # Interactive restore
pt restore <filename> --last # Restore last backup
pt restore <filename> -m "msg" # Restore with comment
pt diff <filename> # Interactive diff
pt diff <filename> --last # Diff with last backup
pt remove <filename> # Delete file (with backup)
pt remove <filename> -m "msg" # Delete with comment
pt tree [path] # Show tree (default: .)
pt tree -e file1,file2 # Exclude files/dirs
pt config init [path] # Create config (default: pt.yml)
pt config show # Display current config
pt config path # Show config file location
Create a pt.yml file in one of these locations:
./pt.yml (current directory)~/.config/pt/pt.yml~/pt.yml# PT Configuration File
# Maximum clipboard content size in bytes (default: 104857600 = 100MB)
max_clipboard_size: 104857600
# Maximum number of backups to keep (default: 100)
max_backup_count: 100
# Maximum filename length (default: 200)
max_filename_length: 200
# Backup directory name (default: "backup")
backup_dir_name: backup
# Maximum directory depth for recursive search (default: 10)
max_search_depth: 10
Generate sample config:
pt config init
All backups are stored in the ./backup/ directory (configurable).
Format: {filename}_{ext}.{timestamp}.{pid}_{random}
Example: notes_txt.20241115_143022123456.12345_a3f4
Each backup includes a .meta.json file containing:
{
"comment": "User-provided comment",
"timestamp": "2024-11-15T14:30:22+07:00",
"size": 1234,
"original_file": "/path/to/original.txt"
}
When a file is not found in the current directory, PT automatically searches subdirectories (up to configured depth).
# File in subdirectory
pt src/main.rs
# If multiple files found, interactive selection:
🔍 Found 3 file(s):
1. ./src/main.rs - 2024-11-15 14:30:22 - 15.2 KB
2. ./backup/main.rs - 2024-11-14 10:20:15 - 14.8 KB
3. ./old/main.rs - 2024-11-10 09:15:30 - 13.5 KB
Enter file number to use (1-3) or 0 to cancel:
PT supports delta for beautiful diffs:
# Install delta
cargo install git-delta
# Use with PT
pt diff notes.txt
Features:
Display directory structure with file sizes:
pt tree
myproject
├── src/
│ ├── main.rs (15.2 KB)
│ └── lib.rs (8.5 KB)
├── Cargo.toml (245 B)
└── README.md (3.1 KB)
2 directories, 4 files, 27.0 KB total
Tree view respects .gitignore patterns automatically.
Exclude specific files/directories:
pt tree -e node_modules,.git,target
Path Validation
..)Size Limits
Backup Limits
0 - Success1 - Error (with descriptive message)Linux: Install xclip or xsel
sudo apt-get install xclip
# or
sudo apt-get install xsel
macOS: Should work out of the box
Windows: Should work out of the box
Install delta for diff functionality:
cargo install git-delta
Check write permissions:
ls -la .
chmod u+w filename.txt
# Morning: Start notes
pt notes.txt -m "Daily standup notes"
# Throughout day: Append updates
pt append notes.txt -m "Meeting outcome"
pt append notes.txt -m "Action items"
# Review changes
pt diff notes.txt --last
# If needed, restore previous version
pt list notes.txt
pt restore notes.txt
# End of day: Archive
mv notes.txt archive/notes_$(date +%Y%m%d).txt
# Quick code snippet storage
pt snippets/query.sql -m "User analytics query"
pt snippets/script.sh -m "Deployment script v1"
# Later: Review and compare
pt list snippets/query.sql
pt diff snippets/query.sql
# Save clipboard content to docs
pt docs/api.md -c -m "API documentation update"
# Tree view of docs
pt tree docs
# Restore if needed
pt restore docs/api.md --last
Contributions welcome! Please:
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 Hadi Cahyadi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Made with ❤️ by Hadi Cahyadi
Your complete file version management system with contextual history in a single command. ⚡
If you find PT useful, consider supporting its development and please consider giving it a star on GitHub! ⭐: