How do I add ~/bin to my path?

I've been having trouble modifying my path to add Sublime Text 2. I've added a ~/bin directory and run this command:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

The subl link appears in ~/bin. But I need to add the ~/bin directory to my path. I'm fairly new at this, and I don't know where my path is. I've looked around, and found that the likely files are either .profile, .bash_profile or .bashrc

I don't have a .bash_profile. To .profile and .bashrc I added

PATH=$PATH:~/bin/subl
export PATH

Is that the right thing to add? And if so, where should I add it?

When I echo $PATH, I get:

/Users/<username>/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/bin:/Users/<username>/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/<username>/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/<username>/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

When I type subl, I get:

-bash: subl: command not found

Thanks!

p.s. I had previously installed Macports, which modified my .profile file. Not sure if this has anything to do with it - I now don't know what the default .profile looks like.


I was just as new to this as you, which means I wasn't even sure how to read half the stuff related to modifying PATH. Eventually though I came upon a way to do it that doesn't require you to put subl into the .rvm/bin (since that is for something else) but in its appropriate directory, which is ~/bin.

Go to your terminal and type:

open -a Finder /usr/bin

This will open your Finder to the /usr/bin directory. Once you're there open a new Finder, go to Applications, right click on the Sublime Text icon and go to Show Package Contents, then to Contents, SharedSupport, bin. Copy the subl file and paste it into the other Finder showing /usr/bin

That's it! You should be set to use the command:

subl . (or subl file.name)

Instread of all commented here. You need add symlink to sublime in /usr/local/bin. Its not require a root access. And don't need to create another bin directory.

For Sublime Text 2

ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/

For Sublime Text 3

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/