cpm2

Crates.iocpm2
lib.rscpm2
version1.0.4
created_at2025-12-20 19:25:35.923149+00
updated_at2025-12-20 19:25:35.923149+00
descriptionA command-line utility written in Rust that copies file paths to the clipboard with various formatting options and sends notifications via Growl.
homepagehttps://github.com/cumulus13/cpm2
repositoryhttps://github.com/cumulus13/cpm2
max_upload_size
id1996877
size80,454
cumulus13 (cumulus13)

documentation

https://docs.rs/cpm

README

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

Hadi Cahyadi

Buy Me a Coffee

Donate via Ko-fi

Support me on Patreon

Contributing

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

Commit count: 0

cargo fmt