Skip to content

LaunchAgent for gitwatch under MacOS

Max Rossmannek edited this page Apr 27, 2020 · 1 revision

Under MacOS, systemctl is not available. However, launchctl provides a similar set of features and can be used to achieve startup automation of custom scripts.

As working LaunchAgent configuration file was developed in this snippet. For simplicity, it is repeated here:

<?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.github.gitwatch</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/gitwatch</string>
        <string>*INSERT ARGUMENTS HERE*</string>
    </array>
    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
    </dict>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

The file above is based on the following assumptions:

  1. gitwatch has been installed under /usr/local/bin
  2. fswatch is installed in any of the directories included in PATH

Procedure

  1. Copy the contents of the above snippet into a file.
  2. Insert the command line arguments for gitwatch as desired.
  3. Save the file under ~/Library/LaunchAgent/com.github.gitwatch.plist. Note: you may change the filename, but if you do, ensure to update the Label in the file accordingly!
  4. Start the agent by logging out and in again or via launchctl load ~/Library/LaunchAgent/com.github.gitwatch.plist