Skip to content

Instantly share code, notes, and snippets.

@devdumpling
Created August 25, 2024 18:06
Show Gist options
  • Save devdumpling/206cddd544be229ef27af50ce7f80c29 to your computer and use it in GitHub Desktop.
Save devdumpling/206cddd544be229ef27af50ce7f80c29 to your computer and use it in GitHub Desktop.
Sync zed config
#!/bin/bash
# This is a simple script to copy non tmp files from zed config to a repo you can use for storing your config.
# This is slightly modified from what I actually use, which stores a number of other config files that I share across machines.
# rsync is used instead of cp for flexibility
ZED_SOURCE_DIR="/Users/USER/.config/zed"
ZED_DEST_DIR="/Users/USER/PATH_TO_SYNC_REPO/.config/zed"
# absolute path to repo storing your config
REPO_DEST_DIR="/Users/USER/PATH_TO_SYNC_REPO"
# Copy zed config
rsync -av --exclude='.tmp*' "$ZED_SOURCE_DIR/" "$ZED_DEST_DIR/"
# Sync
cd "$REPO_DEST_DIR"
git add .
git commit -m "Automatic backup $(date)"
git push origin main
0 3 * * * /bin/bash /Users/USER/PATH_TO_SYNC_REPO/backup_and_push.sh >> /Users/USER/PATH_TO_SYNC_REPO/backup_log.txt 2>&1
@devdumpling
Copy link
Author

devdumpling commented Aug 25, 2024

I used crontab to setup a simple cron on mac.

crontab -e

Syncs at 3AM, feel free to adjust to whatever, and then I have an alias that runs this manually that I will probably never remember to use.

Mine also logs the output to a log so I can see what's going down, but not necessary.

Note: you'll also need to make sure you add git credentials so your cron can push to your settings repo. I used an SSH key but there's lots of ways to accomplish this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment