4

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.

  • Have you tried unhiding it? Also, though I'm not sure if this would work, you could create your own foobar.bash_profile file and set the default program like you stated above. – Luke35 Jun 1 '15 at 20:02
5

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

  • @Mark I think you misunderstood. I updated the instructions. This method sets the default so that it does not open in TextEdit. – Bowen Jun 1 '15 at 22:49
  • this is the correct answer. – les Jun 2 '15 at 1:37
4

What about:

subl .bash_profile

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

  • this doesn't answer the OP – les Jun 2 '15 at 1:35
1

You can do open -a "Sublime Text 2" ~/.profile Assuming that name is what's on the app's bundle.

1

I do this all the time, but i do it from the command line:

My bash profile has the st macro mapped to:

alias st='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl'

And in the terminal i just type:

st ~/.bash_profile

1

Sublime Text Shortcut Guide

  1. Open Mac Terminal
  2. Go to homebrew.sh; copy and enter the following: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. Enter brew install wget
  4. Enter the following into your Mac Terminal: open ~/.bash_profile but if for whatever reason you don't have one configured, enter sudo nano .bash_profile. Please be advised, this solution presumes you are the root user of your system/device.
  5. Open another tab within the terminal-window and check Ruby version (e.g. ruby -v); if absent, become sufficiently by Rubified by entering: brew install ruby
  6. Download Sublime Text 3, then go to root/usr (e.g. cd alexanderjsingleton/).
  7. Next after you've installed Sublime 3, open /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
  8. Create a symlink called sublime by entering ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
  9. Enter the following into your Mac Terminal: open ~/.bash_profile but if for whatever reason you don't have one configured, enter sudo nano .bash_profile.
  10. Exit and open your bash profile; the following example should be contained in the profile export PATH=/usr/local/bin:$PATH. This is the same file location for other user-profile settings for applications like iTerm.
  11. Test by entering the directory of app-files (e.g. sublime .).
  12. Boom! A special thanks to the great Ashley Nolan's blog, though for whatever reason my new MacBookPro couldn't access the bash-profile, so I had to create one, which is why I included that caveat in step 4. I trust this will assuage any systemAdmin anguish fellow developers may take for granted. :D

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .