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.– Luke35Commented Jun 1, 2015 at 20:02
5 Answers
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.
-
@Mark I think you misunderstood. I updated the instructions. This method sets the default so that it does not open in TextEdit.– BowenCommented Jun 1, 2015 at 22:49
-
What about:
subl .bash_profile
instead of open
. You can launch Sublime Text with subl
, and append a filename to open it.
You can do open -a "Sublime Text 2" ~/.profile
Assuming that name is what's on the app's bundle.
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
Sublime Text Shortcut Guide
- Open Mac Terminal
- Go to homebrew.sh; copy and enter the following:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Enter
brew install wget
- Enter the following into your Mac Terminal:
open ~/.bash_profile
but if for whatever reason you don't have one configured, entersudo nano .bash_profile
. Please be advised, this solution presumes you are the root user of your system/device. - 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
- Download Sublime Text 3, then go to root/usr (e.g.
cd alexanderjsingleton/
). - Next after you've installed Sublime 3,
open /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
- Create a symlink called sublime by entering
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
- Enter the following into your Mac Terminal:
open ~/.bash_profile
but if for whatever reason you don't have one configured, entersudo nano .bash_profile
. - 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. - Test by entering the directory of app-files (e.g.
sublime .
). - 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