Skip to content

Instantly share code, notes, and snippets.

@nickyreinert
Last active January 18, 2024 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickyreinert/5ec12cf91fbda37b2af904e491c87578 to your computer and use it in GitHub Desktop.
Save nickyreinert/5ec12cf91fbda37b2af904e491c87578 to your computer and use it in GitHub Desktop.
MacOS automation and workflows
# 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>
# 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