# Sync common directories, setting url to ensure it's up-to-date first SYNC_DIRS=( "$HOME/.password-store/" "$HOME/Documents/org/" "$HOME/Documents/library/" ) 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" ) 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 # Clone ~/.config/emacs/ if it doesn't exist, pull otherwise EMACS_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/emacs" EMACS_URL="https://git.xenia.me.uk/pixelifytica/emacs.git" if [ -d "$EMACS_DIR" ]; then git -C "$EMACS_DIR" remote set-url origin "$EMACS_URL" git -C "$EMACS_DIR" pull --ff --ff-only else git clone "$EMACS_URL" "$EMACS_DIR" fi # Cleanup legacy Emacs config file/directory [ -f "$HOME/.emacs" ] && rm "$HOME/.emacs" [ -d "$HOME/.emacs.d" ] && rm -r "$HOME/.emacs.d"