1 stable release
Uses new Rust 2024
| 1.0.4 | Dec 20, 2025 |
|---|
#1292 in Command line utilities
40KB
164 lines
cpm - Copy Path Manager
A command-line utility written in Rust that copies file paths to the clipboard with various formatting options and sends notifications via Growl.
Features
- 📋 Copy file paths to clipboard instantly
- 🔄 Support for relative and absolute paths
- 🐧 Linux-style path conversion (forward slashes)
- 🌐 URL-style path conversion (file:///)
- 🔔 Growl notifications with custom icon
- ⚡ Fast and lightweight
- 🎯 Flexible argument ordering
Installation
Prerequisites
- Rust and Cargo (install from rustup.rs)
- Growl for Windows (optional, for notifications)
cargo install cpm2
Usage
Quick start
# Without the + sign
cpm ✅ Copy current dir
cpm gntp ✅ Copy C:\PROJECTS\gntp
cpm gntp\build.bat ✅ Copy C:\PROJECTS\gntp\build.bat
cpm gntp\build.bat test ✅ Copy C:\PROJECTS\gntp\build.bat\test
cpm data test file.txt ✅ Copy C:\PROJECTS\data\test\file.txt
# With + sign (optional)
cpm + gntp ✅ Copy C:\PROJECTS\gntp
cpm + gntp\build.bat ✅ Copy C:\PROJECTS\gntp\build.bat
cpm + gntp build.bat ✅ Copy C:\PROJECTS\gntp\build.bat
# With options
cpm gntp -l ✅ Linux style
cpm + gntp -u ✅ URL style
cpm -l gntp build.bat ✅ Flexible order
cpm gntp build.bat -u ✅ Options at the back
Basic Usage
# Copy current directory path
cpm
# Copy relative file path (current directory + file)
cpm test.txt
# Output: C:\current\directory\test.txt
# Copy relative path with subdirectory
cpm data\test.txt
# Output: C:\current\directory\data\test.txt
# Copy absolute path
cpm C:\TEST\test.txt
# Output: C:\TEST\test.txt
Linux Style Paths
Use -l or --linux flag to convert backslashes to forward slashes:
cpm test.txt -l
# Output: C:/current/directory/test.txt
cpm data\test.txt -l
# Output: C:/current/directory/data/test.txt
URL Style Paths
Use -u or --url flag to convert to file URL format:
cpm test.txt -u
# Output: file:///C:/current/directory/test.txt
cpm data\test.txt -u
# Output: file:///C:/current/directory/data/test.txt
Flexible Argument Order
Arguments can be placed before or after the path:
cpm test.txt -u
cpm -u test.txt
cpm -l data\test.txt
cpm data\test.txt -l
Help and Version
# Show help
cpm -h
cpm --help
# Show version
cpm -V
cpm --version
Growl Notifications
When a path is copied, cpm automatically sends a notification to Growl (if running).
Dependencies
- clap - Command-line argument parsing
- clipboard-win - Windows clipboard access
- gntp - Growl Notification Transport Protocol
Examples
Example 1: Copy Config File Path
cpm config\app.json
# Copies: C:\projects\myapp\config\app.json
Example 2: Copy as File URL for Browser
cpm index.html -u
# Copies: file:///C:/projects/website/index.html
# Can be pasted directly into browser address bar
Example 3: Copy for Unix/Linux Scripts
cpm src\main.rs -l
# Copies: C:/projects/myapp/src/main.rs
# Compatible with Unix-style tools
Example 4: Copy Absolute Path
cpm "D:\Documents\Important File.txt"
# Copies: D:\Documents\Important File.txt
Troubleshooting
Clipboard Issues
If clipboard operations fail, ensure:
- You have permission to access the clipboard
- No other application is blocking clipboard access
Growl Notifications Not Working
If notifications don't appear:
- Verify Growl is running
- Check Growl is listening on port 23053
- Ensure firewall allows local connections
- The application will continue working without Growl
Path with Spaces
Use quotes for paths containing spaces:
cpm "My Documents\test.txt"
License
This project is open source and available under the MIT License.
👤 Author
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Dependencies
~1–17MB
~201K SLoC