判断

mdls -name kMDItemContentType yourfilename
比如:
mdls -name kMDItemContentType .zshrc
系统输出: 
kMDItemContentType = "public.data"

Mavericks之前

##要我改下面这个文件, 但是, 我就没找到这个文件.
default application for public.plain-text in
~/Library/Preferences/com.apple.LaunchServices.plist

defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=xxxType;LSHandlerRoleAll=xxx.yyy.sublime;}' 


defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.apple.textedit;}' '{LSHandlerContentType=public.unix-executable;LSHandlerRoleAll=com.apple.textedit;}'

Restart to apply the changes (logging out and back in isn't enough).
#据说直接运行这个是可以的.
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'

defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.macromates.textmate;}' '{LSHandlerContentType=public.unix-executable;LSHandlerRoleAll=com.macromates.textmate;}'
#这个貌似没有效果, 反正我还没有重启机器.
#确实没用, 因为: This answer is for Mavericks and earlier.

从yosmite开始

#我改了这个文件:
/Users/m/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist 
#这个地方:
LSHandlerContentType = "public.comma-separated-values-text";
LSHandlerPreferredVersions = { LSHandlerRoleAll = "-"; };
LSHandlerRoleAll = "com.macromates.textmate"; #这一行, com.apple.textedit

#直接执行这个: 
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'

使用duti

#安装duti用brew
brew install duti
#改配置
com.apple.textedit public.plain-text all
com.macromates.textmate public.unix-executable all
#直接命令行

duti -s com.macromates.textmate public.plain-text all
duti -s com.macromates.textmate public.unix-executable all

重启后, 配置生效了.