cpbar is a lightweight wrapper for cp, mv, and rm commands that adds a unified, beautiful progress bar to your terminal file operations. It is written in Python and designed to be a drop-in replacement for standard file management commands.
- Unified Progress Bar: Tracks total progress across all files and directories.
- Real-Time Speed Display: Shows current transfer speed (MB/s or GB/s) with smoothing for accurate readings.
- Visual Feedback: Shows operation type (π/ποΈ), percentage, progress bar, item count, total size, elapsed time, speed, and current filename.
- Optimized Performance:
- 16MB buffer size for efficient file operations
- Parallel copy mode for large files (> 64MB) using multi-threading
- Can achieve 2-4x faster speeds on SSDs with parallel mode
- Dry-Run Mode (
-n/--dry-run):- Preview exactly what will happen before executing
- Shows: file count, total size, estimated time, and first 10 files to be processed
- Perfect for verifying complex operations before committing
- Parallel Copy Mode (
--parallel=N):- Multi-threaded copying for large files using block-based parallel I/O
- Automatically activates for files > 64MB when enabled
- Configurable worker count (optimal: 4-8 for SSDs)
- Auto-benchmark to detect optimal settings for your system
- Move Support: Full support for moving files and directories (
mv) with progress tracking. - Recursive Support: Fully supports recursive copy (
cp -r), move (mv), and remove (rm -r). - Smart Overwrite Handling:
- Prompts when destination files exist with options: yes (y), no (n), all (a), quit (q).
- All prompts appear in the same line for a clean interface.
- Safety First:
rmasks for confirmation by default with a 3-second safety countdown.rm -fskips confirmation (like standardrm).
- Drop-in Replacement: Installs aliases so you can keep using
cp,mv, andrmas usual. - Original Commands: Provides
cpo,mvo, andrmoaliases if you need the original system commands. - Non-TTY/Script Compatibility:
- Automatically detects if running in a TTY (interactive terminal)
- Falls back to simple line-based output when used in pipes, scripts, or cronjobs
- No ANSI escape codes are printed in non-interactive mode
- Works seamlessly in automation contexts
Download the latest .deb from Releases and install:
wget https://github.com/cfpandrade/cpbar/releases/latest/download/cpbar_<version>_all.deb
sudo dpkg -i cpbar_<version>_all.debBash users get aliases automatically via /etc/profile.d/cpbar.sh (takes effect on next login or source /etc/profile.d/cpbar.sh).
Zsh users: add these lines to ~/.zshrc and reload:
alias cpo='/bin/cp'
alias mvo='/bin/mv'
alias rmo='/bin/rm'
alias cp='cpbar cp'
alias mv='cpbar mv'
alias rm='cpbar rm'To upgrade, just install the new .deb over the old one with sudo dpkg -i.
./install.shThe script will:
- Install the
cpbarpackage to~/.local/lib/cpbar/(library files). - Create an executable wrapper in
~/.local/bin/cpbar(entry point). - Add
~/.local/binto yourPATHif needed. - Configure aliases in your
.zshrcor.bashrc. - Optionally run a benchmark to detect optimal parallel settings for your system (~30 seconds).
After installation, reload your shell configuration:
source ~/.zshrc # or source ~/.bashrcNote: The installer will ask if you want to run a benchmark to optimize performance. This is recommended but optionalβyou can run cpbar benchmark later if you skip it.
Once installed, you can use cp, mv, and rm normally, and they will now show progress bars!
# Copy a single file
cp big_file.iso /mnt/backup/
# Copy a directory recursively
cp -r Photos/ /mnt/backup/Photos/
# Copy multiple files
cp *.jpg /mnt/backup/images/
# Dry-run: preview what would be copied
cp -n -r Photos/ /mnt/backup/
# Parallel copy for large files (2-4x faster on SSDs)
cp -P large_file.iso /backup/ # Use auto-detected optimal workers
cp --parallel=4 large_file.iso /backup/ # Or specify workers manually
cp --parallel=8 huge_database.sql /backup/ # More workers for very large files# Move a single file
mv document.pdf /archive/
# Move a directory
mv old_project/ /archive/old_project/
# Move multiple files
mv *.log /logs/archive/
# Dry-run: preview what would be moved
mv -n -r old_project/ /archive/
# Parallel move for large files (2-4x faster on SSDs across filesystems)
mv -P large_video.mkv /external_drive/ # Use auto-detected optimal workers
mv --parallel=4 database.sql /backup/ # Or specify workers manuallyNote: When moving files within the same filesystem, mv uses instant rename operations. When moving across filesystems, it copies and then deletes the source (showing progress).
# Remove a file (asks for confirmation)
rm old_file.txt
# Remove a directory recursively
rm -r old_folder/
# Force remove (no confirmation)
rm -rf temp_folder/
# Dry-run: preview what would be deleted
rm -n -r old_folder/Before performing potentially risky operations, use the dry-run flag to see exactly what will happen:
# Preview what will be copied
cp -n large_folder/ /backup/
# Preview what will be deleted
rm -n --dry-run old_folder/Dry-run output includes:
- Total number of files to process
- Total size that will be affected
- Estimated time for the operation (80 MB/s for copy, 200 MB/s for delete)
- Preview of the first 10 files
Example output:
π Dry-run mode - No files will be copied
Summary:
Files to copy: 42
Total size: 2.5GB
Estimated time: ~31s
Destination: /backup/
Files (showing first 10):
β photos/vacation_2024/IMG_001.jpg (4.2MB)
β photos/vacation_2024/IMG_002.jpg (3.8MB)
β documents/report.pdf (1.2MB)
... and 39 more files
When copying files that already exist at the destination, cpbar will prompt you for each file:
Overwrite '/path/to/file.txt'? [y/n/a/q]:
Options:
- y (yes) - Overwrite this file
- n (no) - Skip this file
- a (all) - Overwrite all remaining files without asking
- q (quit) - Cancel the entire operation
All prompts appear on the same line for a clean, organized interface.
For copying large files (> 64MB), use parallel mode to significantly speed up transfers on modern SSDs:
# Use parallel mode with auto-detected optimal workers
cp -P large_video.mp4 /backup/
# Or specify a custom number of workers
cp --parallel=4 database_dump.sql /backup/
# Works great with multiple large files
cp -P *.iso /backup/When to use parallel mode:
- β Large files (> 64MB): Significant speed improvements
- β SSD to SSD: 2-4x faster transfer speeds
- β NVMe drives: Best performance with 4-8 workers
- β Small files (< 64MB): Automatically uses normal mode
- β HDD to HDD: May not improve or could be slower
Performance tips:
- Run
cpbar benchmarkto auto-detect the optimal settings for your system - Use
-Pflag to use the benchmarked optimal value - Files > 1GB see the most benefit
- Real-time speed shown in progress bar (watch for MB/s or GB/s)
cpbar can automatically detect the optimal parallel worker count for your specific hardware:
# Run benchmark to detect optimal settings
cpbar benchmark
# The optimal value is saved and becomes the default when using -P
cp -P large_file.iso /backup/What the benchmark does:
- Creates a temporary 100MB test file
- Tests with 1, 2, 4, 6, and 8 workers
- Runs 3 trials for each configuration
- Determines the fastest configuration
- Saves the result to
~/.config/cpbar/config.json
Note: The installer optionally runs the benchmark automatically during installation. You can re-run it anytime if you upgrade your hardware or move to a different system.
cpbar automatically detects when it's not running in an interactive terminal (e.g., in pipes, scripts, or cronjobs) and switches to a simplified output mode:
Interactive mode (TTY):
# Beautiful progress bar with colors and animations
$ cpbar cp large_file.iso /backup/
π 45.2% [βββββββββββββββββββββββββ] 1/1 | 2.1GB/4.6GB | 3m 15s @ 11.2MB/s | large_file.isoNon-interactive mode (no TTY):
# Simple line-based output, no ANSI codes
$ cpbar cp file.txt /backup/ | tee log.txt
Copying 1 files (13.0B)...
Copied [1/1] (100.0%) file.txt
β
Copied: 1 files (13.0B)
# In a script
#!/bin/bash
cpbar cp data.tar.gz /backup/ # Works seamlessly
# In a cronjob
0 2 * * * cpbar rm -rf /tmp/old_backups # Clean output for logs
# Piped with other commands
find . -name '*.log' | xargs cpbar rmWhat changes in non-TTY mode:
- No ANSI escape codes or cursor control
- Simple line-based progress updates instead of animated progress bar
- One line per completed file instead of continuously updating display
- All functionality works identically (dry-run, parallel, confirmation prompts, etc.)
This makes cpbar perfect for automation while still providing progress tracking in logs!
If you need to use the standard system commands without the progress bar wrapper (e.g., for scripts or piping), use the o suffix:
cpo file.txt dest/
rmo file.txt- Python 3
- Linux/macOS (Bash or Zsh)
cpbar calculates the total size of all source files before starting the operation to provide an accurate progress bar. It handles both file-to-file and directory-to-directory operations, preserving metadata where possible.
- Large Buffer: Uses a 16MB buffer (vs standard 1MB) to reduce system calls and improve throughput
- Parallel I/O: When
--parallelis enabled, divides large files into 32MB blocks and copies them simultaneously using multiple threads - Speed Tracking: Monitors transfer speed in real-time with exponential smoothing for stable readings
- Smart Mode Selection: Automatically uses regular copy for files < 64MB even when parallel mode is enabled
In dry-run mode, it scans all files without performing any operations, providing a detailed preview including estimated time based on modern SSD speeds (500 MB/s for copy, 1000 MB/s for delete).
The project is organized as a modular Python package:
cpbar/
βββ cpbar.py # Main entry point
βββ install.sh # Installation script
βββ cpbar/ # Python package
βββ __init__.py # Package initialization
βββ __main__.py # Module entry point
βββ core.py # CLI argument parsing
βββ operations.py # File copy/remove operations
βββ ui.py # Progress bar and UI components
βββ utils.py # Utility functions and config
βββ benchmark.py # Performance benchmarking
Cause: Your terminal doesn't support ANSI escape codes, or you're using an old terminal emulator.
Solution:
- Use a modern terminal (iTerm2, Terminal.app, GNOME Terminal, etc.)
- Update your terminal emulator
- The tool automatically detects TTY and falls back to simple output in non-interactive mode
Cause: Insufficient permissions to read source or write to destination.
Solution:
# Check file permissions
ls -la source_file
# Check destination directory permissions
ls -la /destination/
# Use sudo if necessary (be careful!)
sudo cpbar cp protected_file.txt /system/location/Cause: Not all systems benefit from parallel I/O. HDDs and network drives may perform worse.
Solution:
# Run benchmark to find optimal settings for your system
cpbar benchmark
# For HDDs, use normal mode (don't use -P)
cpbar cp large_file.iso /backup/
# Parallel mode is best for: SSD to SSD, NVMe, and files > 1GBCause: Might be running in non-interactive mode (pipe, script, cron) where prompts aren't possible.
Solution:
- Run the command directly in a terminal for interactive prompts
- Or accept that existing files will be overwritten in batch operations
Cause: Progress tracking adds minimal overhead, but could be Python startup time for very small files.
Solution:
# For single small files, use original cp
cpo tiny_file.txt dest/
# cpbar shines with large files and directories
cpbar cp -r huge_folder/ /backup/
cpbar cp -P multi_gigabyte_file.iso /backup/ # 2-4x faster than cp!Cause: Virtual environment or dependencies issue.
Solution:
# Clean setup
rm -rf .venv
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
pytest tests/ -vCause: Modern Python prevents system-wide pip installs to protect the OS.
Solution:
# Use the install script (recommended)
./install.sh
# Or use a virtual environment
python3 -m venv ~/.cpbar-env
source ~/.cpbar-env/bin/activate
pip install cpbarCause: Very fast operations (< 100ms) don't have enough data to calculate meaningful speed.
Solution: This is normal for small files. Speed tracking works best for operations > 1 second.
Cause: Shell hasn't reloaded configuration.
Solution:
# Reload shell config
source ~/.bashrc # or ~/.zshrc
# Or restart your terminal
# Verify aliases
alias | grep cpbarCause: Python can't find the cpbar package.
Solution:
# Check installation
which cpbar
python3 -m cpbar --version
# Reinstall if needed
./install.sh
# Or verify PATH includes ~/.local/bin
echo $PATH | grep .local/bin-
Use parallel mode for large files (> 1GB):
cpbar cp -P huge_database.sql /backup/
-
Run benchmark to optimize for your hardware:
cpbar benchmark # Then use -P for optimal workers -
SSD to SSD transfers benefit most:
- HDD to HDD: Stick with normal mode
- SSD to SSD: Use
-Por--parallel=4 - NVMe: Can go up to
--parallel=8
-
For many small files, normal mode is best:
- Parallel overhead > benefit for files < 64MB
Carlos Andrade
- Email: carlos@perezandrade.com
- GitHub: @cfpandrade
- Repository: github.com/cfpandrade/cpbar
This project is open source and available under the MIT License.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
Author: Carlos Andrade carlos@perezandrade.com