Set bash_profile to open with Sublime Text 2 by default

I'd like Sublime Text 2, not TextEdit, to be the default program to open my bash_profile file when I call open ~/.bash_profile in Terminal. Normally I would just control-click on the file in Finder to set the default program, but given that bash_profile is hidden I'm not sure how to go about this.


Solution 1:

You can temporarily show hidden files. In terminal write:

defaults write com.apple.finder AppleShowAllFiles TRUE

and then killall Finder to restart Finder.

Change what you need and then hide hidden files again by changing TRUE to FALSE.

Edit: Making this more explicit. In Finder, locate .bash_profile, open up the properties by right click + "Get Info". Then change the "Open with" to Sublime Text 2. This works, I just tried it.

enter image description here

Solution 2:

What about:

subl .bash_profile

instead of open. You can launch Sublime Text with subl, and append a filename to open it.