Skip to content

Latest commit

Β 

History

146 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

cpx

A modern, fast file copy tool for Linux with progress bars, resume capability, and more.

Crates.io License: MIT CI

Features β€’ Installation β€’ Quick Start β€’ Documentation


Why cpx?

cpx is a modern replacement for the traditional cp command, built with Rust for maximum performance and safety on Linux systems.

one

Features

  • πŸš€ Fast parallel copying (upto 5x faster than cp benchmarks)
  • πŸ“Š Beautiful progress bars (customizable)
  • ⏸️ Resume interrupted transfers
  • πŸ›‘ Graceful Ctrl+C handling with resume hints four
  • 🎯 Exclude patterns (gitignore-style)
  • πŸ•³οΈ Sparse files stay sparse (SEEK_DATA/SEEK_HOLE), reflink/CoW copies where supported
  • πŸ§ͺ Tested against the GNU coreutils cp test suite (details)
  • βš™οΈ Flexible configuration

Installation

Quick Install

curl -fsSL https://raw.githubusercontent.com/11happy/cpx/main/install.sh | bash

Or with wget:

wget -qO- https://raw.githubusercontent.com/11happy/cpx/main/install.sh | bash

From Crates.io

cargo install cpx

Arch Linux (AUR)

Added by community

yay -S cpx-copy

Nix / NixOS

Added by community

nix-shell -p cpx

From Source

cargo install --git https://github.com/11happy/cpx
cpx --version

Pre-built Binaries

Download from Releases

Quick Start

Basic Usage

# Copy a file
cpx source.txt dest.txt

# Copy directory recursively
cpx -r source_dir/ dest_dir/

# exclude build artifacts
cpx -r -e "node_modules" -e ".git" -e "target" my-project/ /backup/

# Resume interrupted transfer
cpx -r --resume large_dataset/ /backup/

# Copy with full attribute preservation
cpx -r -p=all photos/ /backup/photos/

See examples.md for detailed workflows and real-world scenarios.

Key Options

cpx [OPTIONS] <SOURCE>... <DESTINATION>
cpx [OPTIONS] -t <DIRECTORY> <SOURCE>...

Arguments:
  <SOURCE>...       Source file(s) or directory(ies)
  <DESTINATION>     Destination file or directory (omitted with -t)

Input/Output Options:
  -t, --target-directory <DIRECTORY>
                           Copy all SOURCE arguments into DIRECTORY
  -e, --exclude <PATTERN>  Exclude files matching pattern (supports globs, comma-separated)

Copy Behavior:
  -r, -R, --recursive      Copy directories recursively
  -a, --archive            Same as -r --no-dereference --preserve=all
  -j <N>                   Number of parallel operations [default: 4]
  -v, --verbose            Print each 'src' -> 'dst' as it is copied
  -u, --update             Copy only when SOURCE is newer than DEST or DEST is missing
  -n, --no-clobber         Never overwrite an existing file
      --resume             Resume interrupted transfers (checksum verified)
  -f, --force              Remove and retry if destination cannot be opened
  -i, --interactive        Prompt before overwrite
      --parents            Use full source file name under DIRECTORY
      --attributes-only    Copy only attributes, not file data
      --remove-destination Remove destination file before copying

Link and Symlink Options:
  -s, --symbolic-link[=MODE]
                           Create symlinks instead of copying [auto|absolute|relative]
  -l, --link               Create hard links instead of copying
  -P, --no-dereference     Never follow symbolic links in SOURCE
  -L, --dereference        Always follow symbolic links in SOURCE
  -H, --dereference-command-line
                           Follow symbolic links only on command line

Preservation:
  -p, --preserve[=ATTRS]   Preserve attributes [default|all|mode,timestamps,ownership,...]
                           Available: mode, ownership, timestamps, links, context, xattr

Backup and Reflink:
  -b, --backup[=MODE]      Backup existing files [none|simple|numbered|existing]
      --reflink[=WHEN]     CoW copy if supported [auto|always|never]

Configuration:
      --config <PATH>      Use custom config file
      --no-config          Ignore all config files

Other:
  -h, --help               Print help information
  -V, --version            Print version information

For complete usage examples, see examples.md

For complete option reference, run cpx --help

Configuration

Set defaults with configuration files:

# Create config with defaults
cpx config init

# View active configuration
cpx config show

# See config file location
cpx config path

Config locations (in priority order):

  1. ./cpxconfig.toml (project-level)
  2. ~/.config/cpx/cpxconfig.toml (user-level)
  3. /etc/cpx/cpxconfig.toml (system-level, Unix only)

Example config (~/.config/cpx/cpxconfig.toml):

[exclude]
patterns = ["*.tmp", "*.log", "node_modules", ".git"]

[copy]
parallel = 8
recursive = false

[preserve]
mode = "default"

[progress]
style = "detailed"

[reflink]
mode = "auto"

See configuration.md for all options and use cases.

Performance

cpx is built for speed. Measured on v0.2.0 (24-core Linux box, tmpfs, warm cache, 5 hyperfine runs; cp and cpx -j4 are the defaults, -j16 is what the benchmarks use):

Tree files cp cpx -j4 cpx -j16 xcp -w16
rust-lang/rust 63k 415 ms 227 ms 141 ms 193 ms
torvalds/linux (2.1 GB) 96k 962 ms 430 ms 240 ms 348 ms
200k small files 200k 942 ms 520 ms 262 ms 380 ms

v0.1.4 had a quadratic planning step: the rust tree took 78 s, the linux tree 154 s, and the 200k-file tree did not finish in ten minutes. Upgrade if you copy large trees.

See benchmarks.md for methodology and more comparisons.

Documentation

Platform Support

Platform Status Notes
Linux βœ… Supported copy_file_range fast path (kernel 4.5+), hole-preserving sparse copies
macOS πŸ§ͺ Experimental compiles and passes the unit/integration tests in CI; not functionally tested on real hardware. Binaries are on the releases page, feedback welcome
Windows πŸ”„ Planned To be released

Quick Start for Developers

git clone https://github.com/11happy/cpx.git
cd cpx

# Run tests
cargo test

# Run clippy
cargo clippy

# Try it out
cargo run -- -r test_data/ test_dest/

Tests

All 68 tests of the GNU coreutils cp test suite are ported as independent reimplementations under tests/gnu and run in CI: 49 pass, 10 are documented differences from GNU cp, 9 need root/SELinux or options cpx does not have. See docs/gnu-compat.md.

cargo build --release
PATH=target/release:$PATH tests/gnu/run.sh

Found wrong behavior? File an issue, PRs for more tests are always welcome!

License

Acknowledgments

Inspired by ripgrep, fd, and the modern Rust CLI ecosystem.

Built with: clap, indicatif, rayon, jwalk, and more.


About

cp reimagined

Resources

Contributing

Stars

445 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages