Install TPM Plugin manager first:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Add the the following line (using crontab -e) to cron to apply the changes hourly
0 * * * * cd ~/dotfiles && git pull origin main && stow -v */ >> ~/dotfiles/stow.log 2>&1
Great! You can use launchd, which is the macOS equivalent of cron, to run your command every hour. Here’s how:
- Open Terminal and create a new
.plistfile:mkdir -p ~/Library/LaunchAgents nano ~/Library/LaunchAgents/com.user.dotfiles.sync.plist
- Add the following content:
<?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>com.user.dotfiles.sync</string> <key>ProgramArguments</key> <array> <string>/bin/bash</string> <string>-c</string> <string>cd ~/dotfiles && git pull origin main && stow -v * >> ~/dotfiles/stow.log 2>&1</string> </array> <key>StartInterval</key> <integer>3600</integer> <!-- Runs every hour --> <key>RunAtLoad</key> <true/> </dict> </plist>
StartIntervalis set to 3600 seconds (1 hour).RunAtLoadensures it runs when the agent is first loaded.
Run:
launchctl load ~/Library/LaunchAgents/com.user.dotfiles.sync.plistThis will schedule your task to run every hour.
You can check if your job is loaded with:
launchctl list | grep com.user.dotfiles.syncIf you ever want to stop the scheduled task:
launchctl unload ~/Library/LaunchAgents/com.user.dotfiles.sync.plist