fix(cp): add unique suffix to rsync backup directory for each user (#10170)
* fix(cp): add unique suffix to rsync backup directory for each user
* fix(cp): use `USERNAME` rather than `USER`
Diff
1diff --git a/plugins/cp/README.md b/plugins/cp/README.md
2index e8a9b6ccc8130bd0223ab8fec381b6baa24f91df..23734243c7f3c30bdc9ae0c6452849a279f60746 100644
3--- a/plugins/cp/README.md
4+++ b/plugins/cp/README.md
5@@ -25,7 +25,7 @@ The enabled options for rsync are:
6 7 * `-hhh`: outputs numbers in human-readable format, in units of 1024 (K, M, G, T).
8 9-* `--backup-dir=/tmp/rsync`: move backup copies to "/tmp/rsync".
10+* `--backup-dir="/tmp/rsync-$USERNAME"`: move backup copies to "/tmp/rsync-$USERNAME".
1112 * `-e /dev/null`: only work on local files (disable remote shells).
1314diff --git a/plugins/cp/cp.plugin.zsh b/plugins/cp/cp.plugin.zsh
15index fe6ea87a860b1d1b251d64a5b2f8816f8b027bc5..a56259106b4b03375525ccaf38f62f4c101421c7 100644
16--- a/plugins/cp/cp.plugin.zsh
17+++ b/plugins/cp/cp.plugin.zsh
18@@ -1,4 +1,4 @@
19 cpv() {
20- rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@"
21+ rsync -pogbr -hhh --backup-dir="/tmp/rsync-${USERNAME}" -e /dev/null --progress "$@"
22 }
23 compdef _files cpv