The cp
command is part of GNU CoreUtils and one of the features that a lot of people wanted to be implemented would be a progress bar, but as this hasn’t happened yet, a programmer created a patch and made it available on GitHub that can be implemented on GNU CoreUtils and you use it!
Installation
The procedure is very simple, just follow the steps:
sudo apt install gcc g++ make build-essential
wget http://ftp.gnu.org/gnu/coreutils/coreutils-8.32.tar.xz
tar xvJf coreutils-8.32.tar.xz
cd coreutils-8.32/
wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.8-8.32.patch
patch -p1 -i advcpmv-0.8-8.32.patch
./configure
make
The binary will be created in the src
directory, ie coreutils-8.32/src/cp
, you can move it to replace the original cp
with the command: sudo cp src/cp $(which cp)
(cp copies cp 😃).
Or create an alias (I think most recommended):
mkdir -p ~/.local/bin
cp src/cp ~/.local/bin/cp
echo 'alias cp="${HOME}/.local/bin/cp"' >> ~/.bashrc
exec $SHELL
And test, example:
Use the
--progress-bar
parameter
cp --progress-bar Documents/Fedora-Workstation-Live-x86_64-33-1.2.iso .
copying at 111,2 MiB/s (about 0h 0m 23s remaining)
Documents/Fedora-Workstation-Live-x86_64-33-1.2.iso 340,9 MiB / 1,9 GiB
[===============================>
If you want to avoid using this parameter, create the alias with the parameter, example:
vim ~/.vimrc
and leave the alias in this file like this:
alias cp="${HOME}/.local/bin/cp --progress-bar"
Close, run source ~/.bashrc
and test without the parameter, it will be included automatically:
cp Documentos/Fedora-Workstation-Live-x85_64-33-1.2.iso .
copying at 111,2 MiB/s (about 0h 0m 23s remaining)
Documentos/Fedora-Workstation-Live-x86_64-33-1.2.iso 340,9 MiB / 1,9 GiB
[===============================>
The same can be used for the mv
command which will also be in src
, however, give preference to the -g
parameter instead of the , it is simpler! But honestly, I don’t see any use in using this in --progress-bar
mv
because things are moved so fast that you don’t even need it.
That’s it for today!