#!/usr/bin/env ruby require 'fileutils' ENV['LC_ALL'] = nil ENV['LC_CTYPE'] = 'en_US.UTF-8' DEBUG = false bundle_dir = "#{ENV['HOME']}/Library/Application\ Support/TextMate/Bundles" pristine_bundle_dir = "#{ENV['HOME']}/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles" dirs = [bundle_dir, pristine_bundle_dir] def update_repos_in_dir(dir, topdir) return if dir =~ /^\.+/ return if dir =~ /^\.DS_Store/ Dir.chdir(dir) pwd = FileUtils.pwd entries = Dir.entries('.') if entries.include?('.svn') puts "found svn in #{pwd}" puts `svn up` puts elsif entries.include?('.git') puts "found git in #{pwd}" puts `git pull` puts elsif DEBUG puts "no repo in #{pwd}" end Dir.chdir('..') end dirs.each do |dir| Dir.chdir(dir) Dir.entries('.').each do |entry| next if dir =~ /^\.+/ next unless File.directory?(dir) update_repos_in_dir(entry, dir) end end `osascript -e 'tell app "TextMate" to reload bundles'` puts "bundles reloaded. done."