-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.sh
37 lines (30 loc) · 945 Bytes
/
sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
dest_server="${1}"
dest_path="${HOME}/dotfiles/"
# helper function
copy_to_limit() {
local src dest
src="${1}"
dest="${2}"
rsync -av --delete --mkpath --bwlimit=12500 "${src}" "${dest_server}:${dest}"
}
copy_to_local_share() {
local xdg_local_prefix source_path
xdg_local_prefix=".local/share/"
source_path="${1}"
copy_to_limit "${source_path}" "${dest_path}${xdg_local_prefix}"
}
copy_to_local_bin() {
local xdg_local_prefix source_path
xdg_local_prefix=".local/bin"
source_path="${1}"
copy_to_limit "${source_path}" "${dest_path}${xdg_local_prefix}"
}
# sync dotfiles config
git ls-files -z | rsync -av --delete --files-from=- --from0 . "${dest_server}:${dest_path}"
# sync .local/share/xxx directory
copy_to_local_share "./.local/share/nvim"
copy_to_local_share "./.local/share/mise"
copy_to_local_share "./.local/share/sheldon"
# sync .local/bin directory
copy_to_local_bin "./.local/bin/"