Files
dotfiles-new/update.sh
2025-06-26 00:59:23 +03:00

102 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# This script syncs dotfiles from ~/.config to this git repository.
# It uses rsync to efficiently copy only changed files.
REPO_PATH="$HOME/repos/dotfiles-new"
CONFIG_PATH="$HOME/.config"
# Common exclude patterns for applications like VSCode, Obsidian, etc.
# This helps to avoid syncing cache, logs, and other transient files.
declare -a excludes=(
--exclude='*Cache*'
--exclude='*cache*'
--exclude='Cache'
--exclude='logs'
--exclude='Crashpad'
--exclude='blob_storage'
--exclude='workspaceStorage'
--exclude='History'
--exclude='Service Worker'
--exclude='GPUCache'
--exclude='Dawn*'
--exclude='*journal*'
--exclude='LOCK'
--exclude='*.log'
--exclude='CachedData'
--exclude='CachedExtensionVSIXs'
--exclude='Code Cache'
--exclude='Session Storage'
--exclude='Shared Dictionary'
--exclude='WebStorage'
--exclude='Backups'
--exclude='sentry'
--exclude='databases'
--exclude='IndexedDB'
--exclude='User/History'
--exclude='User/workspaceStorage'
# More specific exclusions for VSCode/VSCodium/Cursor
--exclude='User/globalStorage'
--exclude='Local Storage'
--exclude='Dictionaries'
--exclude='code.lock'
--exclude='Cookies'
--exclude='CachedProfilesData'
--exclude='languagepacks.json'
)
# List of configurations to sync from ~/.config
# Add new config directory names to this list.
declare -a configs_to_sync=(
"atuin"
"Cursor"
"flameshot"
"kitty"
"MangoHud"
"mpv"
"neofetch"
"obsidian"
"regolith3"
"VSCodium"
)
echo "Starting dotfiles sync..."
# Sync configurations from ~/.config
for config in "${configs_to_sync[@]}"; do
source_path="$CONFIG_PATH/$config"
if [ -d "$source_path" ]; then
echo "Syncing $config..."
# Use --delete to remove files in the repo that are no longer in the source config.
# The exclude patterns are applied here.
rsync -av --delete "${excludes[@]}" "$source_path" "$REPO_PATH/"
else
echo "Warning: Directory $source_path does not exist. Skipping."
fi
done
# Sync individual files like .zshrc
zshrc_path="$HOME/.zshrc"
if [ -f "$zshrc_path" ]; then
echo "Syncing .zshrc..."
rsync -av "$zshrc_path" "$REPO_PATH/"
else
echo "Warning: File $zshrc_path does not exist. Skipping."
fi
echo "Sync complete."
# Add changes to git
cd "$REPO_PATH"
echo "Adding changes to git..."
git add --all
echo "----------------------------------------"
echo "Dotfiles sync finished."
echo "Review the changes and commit with:"
echo "git commit -m \"update dotfiles\""
echo "And push with: git push"
echo "----------------------------------------"