nixos/home/scripts/shell/git-sync-all.sh
Evie Litherland-Smith 763a1d2a05 Merge home-manager config back in to nixos config
Place home-manager config under home directory, move system config
under system directory.

Add hostname-specific entries under home directory to be consistent
with how system is configured, update flake accordingly
2024-07-03 07:15:39 +01:00

59 lines
1.6 KiB
Bash
Executable file

# Clone ~/.emacs.d/ and ~/.config/home-manager if then don't exist,
# pull otherwise (ff only)
PULL_DIRS=(
"$HOME/.emacs.d/"
"${XDG_CONFIG_HOME:-$HOME/.config}/home-manager"
)
PULL_URLS=(
"https://git.xenia.me.uk/pixelifytica/emacs.git"
"https://git.xenia.me.uk/pixelifytica/home-manager.git"
)
for i in "${!PULL_DIRS[@]}"; do
DIRECTORY="${PULL_DIRS[$i]}"
URL="${PULL_URLS[$i]}"
echo "--- $DIRECTORY ---"
if [ ! -d "$DIRECTORY" ]; then
git clone "$URL" "$DIRECTORY"
fi
(
cd "$DIRECTORY" || exit
git remote set-url origin "$URL"
git pull --ff --ff-only
git status --porcelain
)
done
# Sync common directories, setting url to ensure it's up-to-date first
SYNC_DIRS=(
"$HOME/.password-store/"
"$HOME/Documents/org/"
"$HOME/Documents/library/"
"$HOME/Documents/notebooks/"
)
SYNC_URLS=(
"https://git.xenia.me.uk/pixelifytica/pass.git"
"https://git.xenia.me.uk/pixelifytica/org.git"
"https://git.xenia.me.uk/pixelifytica/library.git"
"git@git.ccfe.ac.uk:elitherl/notebooks.git"
)
for i in "${!SYNC_DIRS[@]}"; do
DIRECTORY="${SYNC_DIRS[$i]}"
URL="${SYNC_URLS[$i]}"
echo "--- sync: $DIRECTORY ---"
if [ ! -d "$DIRECTORY" ]; then
git clone "$URL" "$DIRECTORY"
fi
(
cd "$DIRECTORY" || exit
git remote set-url origin "$URL"
if [ "$(git branch --show-current)" = "main" ]; then
git branch --set-upstream-to=origin/main main
fi
git pull --ff --ff-only
git submodule update --remote --recursive
git-sync -ns
git status --porcelain
)
done