Code Monkey home page Code Monkey logo

Comments (13)

michaeljoelphillips avatar michaeljoelphillips commented on July 20, 2024

In Linux I added the script to my Startup Applications (Gnome). Have you tried that?

from git-dude.

ku1ik avatar ku1ik commented on July 20, 2024

I'm not OSX expert but maybe you could try running it on startup with launchd? @ml suggested this as the best way to run it in OSX.

from git-dude.

ku1ik avatar ku1ik commented on July 20, 2024

I meant launchctl, not launchd.

from git-dude.

maxcountryman avatar maxcountryman commented on July 20, 2024

Working on this now. If I can get it working I'll send a pull request your way if you like, might be useful to other OS X users out there.

from git-dude.

maxcountryman avatar maxcountryman commented on July 20, 2024

Unfortunately it seems like running this from launchd isn't working: it's able to run the script as would crond but the output isn't properly formatted and is not sent to growl-notify. Perhaps there's another way?

from git-dude.

ku1ik avatar ku1ik commented on July 20, 2024

Unfortunately I can't help you as I'm not using OSX.

from git-dude.

stehlikio avatar stehlikio commented on July 20, 2024

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.

from git-dude.

digitaljhelms avatar digitaljhelms commented on July 20, 2024

While @StehlikC's solution works, I decided to roll my own launchctl solution, and the only issue I ran into involved scoping of the PATH environment variable (my console log was littered with "command not found" errors for git, sleep, date, and basename).

While the PATH environment variable is being set in my ~/.bashrc file (which is sourced from my ~/.bash_profile file) the ~/.bashrc file is only invoked for shells which are not login shells, so this won't work. I assumed launchctl could use the directories specified in my /etc/paths file, but that wasn't the case. launchctl also didn't observe the files in /etc/paths.d which contain path entries...

To my knowledge there are two "acceptable" routes to take for scoping the PATH environment variable for GUI/loginwindow processes:

  1. Use a ~/.launchd.conf file which calls the setenv environment variable function to insert the PATH environment variable name into the current environment list.
  2. Use a special property list file located at ~/.MacOSX/environment.plist which the loginwindow application looks for to set user session environment variables.

I chose the latter of the two, and here's the contents of the property list file I created:

<?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>PATH</key>
     <string>/bin:/usr/bin:/usr/local/git/bin</string>
</dict>
</plist>
  • /bin is needed for the date and sleep commands, as well as where (per the Readme instructions) git-dude has been installed
    • I actually cloned the git-dude repository to a local sandbox area and symlinked the git-dude bash script into /usr/local/bin so my PATH string also needed to include /usr/local/bin
  • /usr/bin is needed for the basename command
  • /usr/local/git/bin is where the git binary lives

A second property list file is needed to rig up launchctl to kick off the git-dude "daemon" at login. The file should live in ~/Library/LaunchAgents and use reverse domain name notation (I went with 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>git-dude</string>
          <string>/Users/<username>/.git-dude</string>
     </array>
     <key>RunAtLoad</key>
     <true/>
</dict>
</plist>
  • Replace <username> with your OS X user account name
  • Depending on where you have git-dude installed, you may need to prefix the git-dude command with a full path
  • 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, you can run the following commands and watch your console log using Console.app:

$ launchctl setenv PATH /bin:/usr/bin:/usr/local/git/bin
$ launchctl load ~/Library/LaunchAgents/com.sickill.git-dude.plist

If the PATH environment variable is incorrect (you'll know because the console log will contain "command not found" errors) make any necessary changes and run the setenv command again. If something is wrong with the property list file for configuring git-dude you can unload the file (change load to unload in the second command above), make necessary changes, and run the load command again.

One nice thing is that once you've got everything set up for git-dude you can use the same configuration steps to run other scripts using launchctl at startup.

Hope this helps someone. Cheers!

from git-dude.

ku1ik avatar ku1ik commented on July 20, 2024

Thx for your input @StehlikC and @digitaljhelms !

from git-dude.

digitaljhelms avatar digitaljhelms commented on July 20, 2024

No worries. Might be worth shoving this into a wiki page...

from git-dude.

ku1ik avatar ku1ik commented on July 20, 2024

I've put these instructions on Wiki: https://github.com/sickill/git-dude/wiki/Daemonizing

from git-dude.

digitaljhelms avatar digitaljhelms commented on July 20, 2024

Sorry to resurrect an old thread, but http://support.apple.com/kb/TS4267 indicates my instructions for using an environment.plist file with launchd is no longer valid for OS X Lion v10.7.4 or higher; I wasn't aware of this change as I jumped over Lion v10.7.4 in a recent upgrade from Lion v10.7.3 to Mavericks v10.9.

Anyway, my approach using launchd still works, but is a lot less cumbersome as it all comes down to the PATH environment variable; as long as that's setup properly to include the paths where git, git-dude, date, and sleep live, you should be golden. RTFM for help: man path_helper

I've updated the wiki page on Daemonizing accordingly.

from git-dude.

ku1ik avatar ku1ik commented on July 20, 2024

Awesome, thanks!

from git-dude.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.