Created
August 25, 2024 18:06
-
-
Save devdumpling/206cddd544be229ef27af50ce7f80c29 to your computer and use it in GitHub Desktop.
Sync zed config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used crontab to setup a simple cron on mac.
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.