Skip to content

Instantly share code, notes, and snippets.

@simonwhitaker
Created July 1, 2012 12:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonwhitaker/3028343 to your computer and use it in GitHub Desktop.
Save simonwhitaker/3028343 to your computer and use it in GitHub Desktop.
Flip your TextMate file type associations to use Sublime Text 2 instead
#!/bin/sh
# Quick and dirty script to flip all the file type currently
# associated with TextMate to be associated with Sublime Text 2
# instead.
#
# DISCLAIMER: worked for me, might not work for you. Use at your
# own risk. I accept no responsibility if you trash your system.
# Specify the plist file we need to tweak
plist="$HOME/Library/Preferences/com.apple.LaunchServices.plist"
# Backup the current file
cp $plist $plist.$(date "+%Y%m%d")
# Convert the plist to JSON format
/usr/bin/plutil -convert json $plist
# Replace instances of "com.macromates.textmate" with "com.sublimetext.2"
/usr/bin/perl -pi -e 's/com\.macromates\.textmate/com.sublimetext.2/g' $plist
# Convert back to binary format
/usr/bin/plutil -convert binary1 $plist
# Reset the launch services DB to pick up the new settings.
# Not 100% sure you actually need to do this but doesn't seem
# to do any harm
/System/Library/Frameworks/CoreServices.framework/Frameworks/\
LaunchServices.framework/Versions/Current/Support/lsregister -kill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment