Skip to content
Jeremy Helms edited this page Dec 4, 2013 · 4 revisions

Running git-dude as daemon

OSX

@StehlikC's solution

This is my solution on OS X ( still kind of new to mac myself ). Let me know what you think, don't think it's something to add to the project though.

#!/bin/bash
#
# run-gd - Simple script to run git-dude on mac-osx login
#

watchdir=$(git config dude.watchdir)

if [ -n $watchdir ]; then
	git dude $watchdir	
fi

I created a simple script inside my ~/.git-dude/ directory called run-gd, make it exec

$ sudo chmod +x ~/.git-dude/run-gd

Add a directory to watch in your git config

$ git config --global dude.watchdir ~/repo-directory

In OS X click

Apple->System Preferences->Users & Groups->[Select User]->Login Items 

and add the shell script and mark it as hidden on launch.

Use cmd+shift+g to search for a hidden folder while in Finder.

@digitaljhelms' solution using launchd

While your PATH environment variable is usually set in a ~/.bashrc or ~/.bash_profile file, those files are only invoked for shells which are not login shells, so this poses a problem when daemonizing. Fortunately launchd uses the path_helper for constructing the PATH environment variable, so just make sure you have /etc/paths or /etc/paths.d setup properly (man path_helper for more info).

A property list file is needed to rig up launchctl to kick off the git-dude "daemon" at login using launchd. The file should live in ~/Library/LaunchAgents, use reverse domain name notation (ie, com.sickill.git-dude.plist) and contain the following:

<?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>KeepAlive</key>
     <true/>
     <key>Label</key>
     <string>com.sickill.git-dude</string>
     <key>LowPriorityIO</key>
     <true/>
     <key>ProgramArguments</key>
     <array>
          <string>/usr/local/bin/git-dude</string>
          <string>/Users/{{username}}/.git-dude</string>
     </array>
     <key>RunAtLoad</key>
     <true/>
</dict>
</plist>
  • Depending on where you have git-dude installed, you may need to adjust the /usr/local/bin path
  • Replace {{username}} with your OS X user account name
  • If the repositories you want git-dude to watch don't live (or aren't symlinked) in the ~/.git-dude directory, specify the correct path

To test everything without constantly rebooting, run the following commands and watch your console log using Console.app:

$ launchctl load ~/Library/LaunchAgents/com.sickill.git-dude.plist

If the PATH environment variable loaded by launchd using the path_helper is incorrect (you'll know because the console log will contain "command not found" errors) simply unload the file (change load to unload in the command above), make necessary changes, and run the load command again.