A CLI tool that watches for changes in files or directories and copies the changed files to a target destination.
- Watch a single file or directory for changes
- Automatically copy changed files to the target destination
- Preserve directory structure when copying from a directory to another
- Initial copy of all files when watching directories
- Auto-create destination directories as needed
- Built-in versioning support
The easiest way to install CPW on macOS or Linux is via Homebrew:
# Add the tap
brew tap mxvsh/cpw
# Install CPW
brew install cpwYou can download pre-built binaries for ARM64 and ARM architectures from the GitHub Releases page.
Available platforms:
- Linux ARM64 (aarch64)
- Linux ARM (armv7)
- macOS ARM64 (Apple Silicon)
# Clone the repository
git clone https://github.com/mxvsh/cpw.git
cd cpw
# Build the binary
make build
# Or build with a specific version
make build VERSION=v1.0.0
# Optionally move to a directory in your PATH
cp cpw /usr/local/bin/# Basic usage
cpw <source> <destination>
# Check version
cpw -versionWatch a single file and copy it when changed:
cpw /path/to/source/file.txt /path/to/destination/file.txtWatch a directory and copy any changed files with the same directory structure:
cpw /path/to/source/dir /path/to/destination/dir- The program starts by checking if both source and destination locations exist
- If watching a directory, it initially copies all files to the destination
- The program then monitors the source for file changes (write or create events)
- When a change is detected, the file is copied to the destination, preserving directory structure
- If new directories are created, they are automatically added to the watch list
CPW includes built-in versioning that displays:
- Version number (from Git tag)
- Commit SHA
- Build date
This information is automatically included in builds when:
- Building with
make build VERSION=v1.0.0 - Creating a release with GitHub Actions
You can view the version information by running:
cpw -versionThis project uses GitHub Actions to automatically build and release binaries for different architectures:
- When a tag is pushed with the format
v*(e.g.,v1.0.0), GitHub Actions will:- Build binaries for ARM64 and ARM architectures
- Include version information in the builds
- Create a GitHub release with these binaries
- Generate release notes
- Update the Homebrew formula
- github.com/fsnotify/fsnotify - File system notifications for Go