nix/module/common/bash/module/Cp.nix

35 lines
890 B
Nix
Raw Normal View History

2024-04-06 03:03:58 +03:00
{ ... }: {
text = ''
# Replaces default cp with rsync.
# Usage: rcp <FROM> <TO>
function rcp() {
rsync -ahP --chmod=u+w "''${@}"
}
# Copy and also merge all changes (delete dst files that do not exist in src).
# Usage: rcp_merge <FROM> <TO>
function rcp_merge() {
rsync -ahP --chmod=u+w --delete "''${@}"
}
2024-04-12 13:10:40 +03:00
# Copy and also merge all changes FAST (delete dst files that do not exist in src, only compare size).
# Usage: rcp_merge_fast <FROM> <TO>
function rcp_merge_fast() {
rsync -ahP --chmod=u+w --delete --size-only "''${@}"
}
2024-04-06 03:03:58 +03:00
# Copy by creating hardlinks.
# Works for directories, too.
# Usage: cp_link <FROM> <TO>
function cp_link() {
/usr/bin/env cp -lr "''${@}"
}
# Print output of cp_merge without writing anything.
# Usage: rcp_test <FROM> <TO>
function rcp_test() {
rsync -ahP --chmod=u+w --delete -n "''${@}"
}
'';
}