Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd love it if I could somehow make the Finder color-label all folders containing a .git directory so I could tell at a glance if the folder is a Git repo. Any ideas?

share|improve this question
Use Folder Actions… – user588 Jul 2 '12 at 22:52
@mankoff thanks for the suggestion, but aren't folder actions tied to specific folders? Or can I make a folder action that is attached to ALL folders, even newly created ones? – bernk Jul 3 '12 at 9:41
Oh you are probably right. OK. Perhaps you'll need to code. See SCPlugin, the SVN Finder Plugin. It changes folder and file icons based on SVN status. – user588 Jul 3 '12 at 12:56
Or, cron job with a 'find' or 'mdfind' command, calling AppleScript? There are an infinite number of hack-ish ways to do this. Not sure about the best formal method. – user588 Jul 3 '12 at 12:57

Saw this question and realized the answer would be useful to me too. Here's the Applescript I came up with. Copy it into Applescript Editor, and adjust the two variables theSearchPath (first line) and the index number at the end of the set label index line and you should be good to go.

I'm searching ~/projects and coloring the results green in this case.

set theSearchPath to "/Users/Me/projects"
set theResults to do shell script "find " & quoted form of theSearchPath & " -name .git"

repeat with i from 1 to (count paragraphs of theResults)
  set theResult to paragraph i of theResults
  set theParentPath to text 1 through ((length of theResult) - 5) of theResult
  set theParentAlias to POSIX file (theParentPath) as alias
  tell application "Finder"
    set label index of theParentAlias to 6
    -- Set the last value of the above line to correspond with the color you want.
    -- 0 is no color
    -- 1 is orange
    -- 2 is red
    -- 3 is yellow
    -- 4 is blue
    -- 5 is purple
    -- 6 is green
    -- 7 is gray
  end tell
end repeat

Note: It hasn't been written to gracefully handle errors spit out by the find command. As long as you're searching directories you have permissions on, this shouldn't be an issue.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.