How to add ~ / bin to your path?

I am having problems changing the path for adding Sublime Text 2. I added the ~/bin and ran 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 to my path. I am new to this and I do not know where my path is. I looked around and found that the probable files are .profile , .bash_profile or .bashrc

I do not have .bash_profile . In .profile and .bashrc I added

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

Is this 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 print subl , I get:

 -bash: subl: command not found 

Thank!

ps I previously installed Macports, which modified my .profile file. Not sure if this is due to this - now I don’t know what the default .profile looks like.

+61
bash sublimetext macos
May 26 '12 at 15:58
source share
13 answers

I was just as new to this as you are, which means that I was not even sure how to read half the material related to changing PATH. In the end, although I found a way to do this, it doesn’t require you to put subl in .rvm / bin (since this is for something else), but in its corresponding directory, which is ~ / bin.

Go to your terminal and type:

 open -a Finder /usr/bin 

This will open your Finder in the / usr / bin directory. As soon as you open a new Finder, go to “Applications”, right-click the “Sublime Text” icon and go to “Show Package Contents” and then to “Content”, SharedSupport, bin. Copy the subl file and paste it into another Finder showing / usr / bin

What is it! You should use the command:

 subl . (or subl file.name) 
+83
Sep 03 '12 at 13:40
source share

Read all comments. You need to add a symlink to sublime in /usr/local/bin . It does not require root access. And no 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/ 
+41
Sep 30 '14 at 4:53
source share

Update for zsh For some reason, "~ / bin" in my path did not work when I recently switched from bash to zsh / prezto. I changed it to "/ Users / myusername / bin" and it works fine again. I will look for the cause and update when I find it. Please comment if you have a better solution.

I know this is an old post, but I thought I would document the solution for anyone trying to follow the instructions given by sublimetext for working with sublime from the OSX command line verbatim. Sublime Text 3 Update Sublime Text 3 Documentation

1) Create the directory "bin" "~ /" in your home directory

 mkdir ~/bin 

2) Create a symbolic link to your exalted text application 2 in the newly created directory

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

The update for the Sublime Text 3 site is slightly different:

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

3) Follow Ryan Hoffman's instructions on how to easily add to a path in OSX: add a path to Mac OSX Add a newly created "~ / bin" to the path using its technique. Your / etc / paths file will look something like this when you are done (note the ~ / bin at the end):

 /usr/bin /bin /usr/sbin /sbin /usr/local/bin ~/bin 

4) Open a new terminal window to start using subl from the command line.

+34
Jul 18 '13 at 19:06
source share

You do not need to do PATH=$PATH:~/bin/subl . Instead, PATH=$PATH:~/bin enough. This way you tell the shell to look in ~/bin for the binaries. With your team, you told the shell to look into the ~/bin/subl "folder" for binaries, which does not work. In addition, you do not need to add commands to two files. Add them once to your .bashrc . I am not a bash expert, but I can recommend reading this blog post to further explain the various startup files.

+11
May 26 '12 at 17:46
source share

I would like to introduce an alternative solution to this problem. Use the directory already on your way. Like this:

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

TL; dg

I ran into the same problem in Yosemite (OS X 10.10), where in the new OS installation the ~ / bin directory does not exist and is not in your path. However, there are many useful places in your path where you can place a symbolic link to Sublime.

For example, here are the elements in my path (use $ echo $PATH to get the list):

 /Applications/Postgres.app/Contents/Versions/9.3/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin:/usr/local/bin /usr/local/mysql/bin 

You can easily modify the script to use the location already in your path by changing the part that says ~/bin/subl to /usr/local/bin/subl

Thus, executing the following command will complete your task.

 $ sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl 
+6
Dec 22 '14 at 18:25
source share

You need to first create a symlink to /usr/bin . A symlink - or SymLink - is an alias or shortcut to a directory. Do the following:

  • First make sure you are in your home directory using the terminal command line

    cd ~

  • Create a symlink in your usr/bin .

    ln -s /usr/bin bin

    Where ln = create a link, -s = symbolic, and then [target diectory] and [name of link]

  • Check your new link

    cd bin

    This will lead you to your ~/bin - the same as /usr/bin . ~ indicates that a long way is hidden inside it.

  • Now go back to your home folder to install the subl command

    cd ~

  • Install the Sublime Text 2 command line tool. I will use sudo to bypass all permission blocks.

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

    You must be good! Test it by simply entering subl as the command line, and it should start Sublime Text 2 from the terminal.

+3
Feb 14 '14 at 16:22
source share

had the same task and ended up just creating a .bash_profile file and adding a direct path statement. Worked without incident. You can also check out Alvin Alexander sample.bash_profile post ( http://alvinalexander.com/blog/post/mac-os-x/sample-mac-osx-bashrc-terminal-startup-file ) - I found a couple of other useful commands which I will add as well.

+2
Jan 28 '13 at 17:50
source share

In a simple way, this is done on the terminal:

 sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl 

My Sublime is stored here, try entering the path to Sublime, because your version may be different.

 subl . 

It should work fine.

+2
Apr 04 '14 at
source share

I recently struggled with this problem. I realized that ~ does not apply to your home directory in transit. At least it was not for me.

This is what I did to make it work.

 export PATH=$PATH:$HOME/bin 

My subl was linked from the application directory to my ~/bin for some of the subsequent instructions that I found for brew cask. Unfortunately, the path was not updated.

+1
Jun 09 '14 at 23:46
source share

Here are the complete instructions for this (for Sublime Text 3 ):

  • Verify the system integrity protection status with the following command:

     $ csrutil status 

    If it is turned on, follow these steps:

    • Boot into OS X recovery OS by restarting the machine and holding Command + R at startup.

    • Launch the terminal from the Utilities menu.

    • Run the following command:

       $ csrutil disable $ reboot 

    This is due to the OS X security feature called System Integrity Protection , which protects against unauthorized access to system locations and processes. Therefore, if this function is enabled , you will not be able to modify the contents of / usr / bin.

  • Create a symlink from / usr / bin to ~ / bin :

     $ sudo ln -s /usr/bin ~/bin 
  • Create a symlink from the CLI Sublime Text 3 tool in ~ / bin :

     $ sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl ~/bin 
  • Check it out.

     $ subl . 
+1
Jun 18 '16 at 18:15
source share
 echo $PATH 

and use one of the existing path. In this example, "/ usr / local / bin"

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

if the system returns No such file or directory

 sudo mkdir /usr/local/bin/ sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl 

check if it works

 subl 

This is for Sublime Text 3.

+1
Aug 05 '17 at 3:50
source share

after working with me. I have Sublime version 3 and post it here if someone is looking for help:

 sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /bin/subl 
0
03 Oct '13 at 13:05
source share

It seems that in Yosemite the command is actually for Sublime 3, but I could be wrong:

  ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/ 
0
Aug 05 '15 at 1:15
source share



All Articles