Repository navigation
Expand file tree
/
Copy pathsync.sh
More file actions
executable file
·58 lines (52 loc) · 2.3 KB
/
Copy pathsync.sh
File metadata and controls
executable file
·58 lines (52 loc) · 2.3 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
# Copy the live configs on this machine into the repo (one-way: $HOME -> repo).
# Each package mirrors $HOME, so install.sh can link it straight back.
#
# ./sync.sh refresh every package
# ./sync.sh nvim refresh only the listed packages
set -euo pipefail
REPO="$(cd "$(dirname "$0")" && pwd)"
cd "$HOME"
# package : paths relative to $HOME (files or directories)
declare -A PACKAGES=(
[niri]=".config/niri"
[noctalia]=".config/noctalia/bar.toml .config/noctalia/services.toml .config/noctalia/shell.toml
.config/noctalia/theme.toml .config/noctalia/widgets.toml .config/noctalia/templates
.local/state/noctalia/settings.toml .local/bin/noctalia-state-watch.sh"
[turntable]=".local/share/noctalia/plugins/turntable .local/share/fonts/nocturne"
[nvim]=".config/nvim"
[zsh]=".zshrc .zshenv .p10k.zsh"
[git]=".gitconfig .config/git/ignore"
[terminals]=".config/alacritty/alacritty.toml .config/kitty/kitty.conf .config/ghostty/config"
[tools]=".config/fastfetch .config/btop/btop.conf .config/cava/config .config/MangoHud/MangoHud.conf"
[cp]="CP/lib/template.cpp CP/lib/debug.h"
)
# never copied: VCS data, logs, backups, caches, generated plugin data
EXCLUDES=(--exclude=.git --exclude='*.log' --exclude='*.bak' --exclude='*.bak.*' --exclude='*.old'
--exclude='__pycache__' --exclude='plugins/turntable/data')
selected=("$@")
[ ${#selected[@]} -eq 0 ] && selected=("${!PACKAGES[@]}")
for pkg in "${selected[@]}"; do
[ -n "${PACKAGES[$pkg]+x}" ] || { echo "unknown package: $pkg" >&2; exit 1; }
for path in ${PACKAGES[$pkg]}; do
if [ ! -e "$path" ]; then
echo " skip $pkg/$path (missing)"
continue
fi
mkdir -p "$REPO/$pkg/$(dirname "$path")"
if [ -d "$path" ]; then
rsync -a --delete "${EXCLUDES[@]}" "$path/" "$REPO/$pkg/$path/"
else
rsync -a "$path" "$REPO/$pkg/$path"
fi
done
echo "synced $pkg"
done
# The repo is public: keep the home city and the personal email out of it.
NOREPLY="59790915+Tejas242@users.noreply.github.com"
if [ -f "$REPO/git/.gitconfig" ]; then
sed -i -E "s/^(\s*email = ).*/\1$NOREPLY/" "$REPO/git/.gitconfig"
fi
if [ -f "$REPO/noctalia/.config/noctalia/services.toml" ]; then
sed -i -E 's/^(address\s*=\s*).*/\1""/' "$REPO/noctalia/.config/noctalia/services.toml"
fi