Last active
January 18, 2024 06:46
-
-
Save nickyreinert/5ec12cf91fbda37b2af904e491c87578 to your computer and use it in GitHub Desktop.
MacOS automation and workflows
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
# 2. The same as 1. but instead of watching changes, this script runs sheduled | |
# use this for larger folders | |
# either use https://launched.zerowidth.com/plists/rt8LaZeMvL or follow those steps | |
# create a folder for this LaunchAgent | |
mkdir -p ~/Library/LaunchAgents | |
# create a LaunchAgent file | |
nano ~/Library/LaunchAgents/launched.sycn.plist | |
launchctl load -w ~/Library/LaunchAgents/launched.sycn.plist | |
launchctl list | grep sync | |
# content of the file, replace "ADD RSYNC COMMAND" with your command | |
# this LaunchAgent runs every day at 9am | |
# if this requires a particular network share, you may use if/then or a bash scrip | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>launched.sync</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>sh</string> | |
<string>-c</string> | |
<string>ADD RSYNC COMMAND</string> | |
</array> | |
<key>StartCalendarInterval</key> | |
<array> | |
<dict> | |
<key>Hour</key> | |
<integer>9</integer> | |
<key>Weekday</key> | |
<integer>1</integer> | |
</dict> | |
</array> | |
</dict> | |
</plist> |
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
# 1. Automator script to sync local development files to a remote storage | |
# create a folder action and assign it to the folder you want to watch | |
# this command will sync files from source folder to the remote folder | |
# it excludes a couple of folders that don't contain important files | |
sync --archive \ | |
--extended-attributes \ | |
--delete \ | |
--exclude='.venv' \ | |
--exclude='.vscode' \ | |
--exclude='*DS_Store*' \ | |
--exclude='.git*' \ | |
--exclude='.env' \ | |
--exclude='__pycache__' \ | |
--cvs-exclude \ | |
source/ \ | |
target \ | |
>> ~/log.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment