This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Cp.sh

31 lines
668 B
Bash
Raw Normal View History

2023-12-07 04:02:47 +03:00
# Replaces default cp with rsync.
# Usage: cp <FROM> <TO>
2023-12-07 01:44:42 +03:00
function cp() {
2023-12-24 16:03:10 +03:00
rsync -ahP --chmod=u+w "${@}"
2023-12-07 00:42:06 +03:00
}
2023-08-08 16:24:15 +03:00
2023-12-07 04:02:47 +03:00
# Copy and also merge all changes (delete dst files that do not exist in src).
# Usage: cp_merge <FROM> <TO>
2023-12-07 01:44:42 +03:00
function cp_merge() {
2023-12-24 16:03:10 +03:00
rsync -ahP --chmod=u+w --delete "${@}"
2023-12-07 00:42:06 +03:00
}
2023-08-08 16:24:15 +03:00
2023-12-07 04:02:47 +03:00
# Copy by creating hardlinks.
# Works for directories, too.
# Usage: cp_link <FROM> <TO>
2023-12-07 01:44:42 +03:00
function cp_link() {
2023-12-24 16:03:10 +03:00
/usr/bin/cp -lr "${@}"
2023-12-07 00:42:06 +03:00
}
2023-08-08 16:24:15 +03:00
2023-12-07 04:02:47 +03:00
# Default cp, a.k.a builtin cp.
# When you don't need rsync.
2023-12-07 01:44:42 +03:00
function bcp() {
2023-12-07 00:42:06 +03:00
/usr/bin/cp "${@}"
}
2023-12-07 04:02:47 +03:00
# Print output of cp_merge without writing anything.
# Usage: cp_test <FROM> <TO>
2023-12-07 01:44:42 +03:00
function cp_test() {
2023-12-24 16:03:10 +03:00
rsync -ahP --chmod=u+w --delete -n "${@}"
2023-12-07 00:42:06 +03:00
}