How do I add ~/bin to my path?

前端 未结 13 911
太阳男子
太阳男子 2020-12-22 19:30

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/Sub         


        
相关标签:
13条回答
  • 2020-12-22 19:47

    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)
    
    0 讨论(0)
  • 2020-12-22 19:48

    You need to first create a symbolic link to /usr/bin. A symbolic link - or SymLink - is an alias or shortcut to a directory. Do as follow:

    1. First, make sure you are in your Home directory using the Terminal command line

      cd ~

    2. Create a symbolic link to your usr/bin directory.

      ln -s /usr/bin bin

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

    3. Test your new link

      cd bin

      This should take you to your ~/bin - same as /usr/bin. The ~ indicates there's a long path hidden inside.

    4. Now, go back to your Home folder to install the subl command

      cd ~

    5. Install the Sublime Text 2 command line tool. I'll be using sudo to bypass any permission blocks.

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

      You should be good to go! Test it by simply entering subl as your command line and it should launch Sublime Text 2 from Terminal.

    0 讨论(0)
  • 2020-12-22 19:49

    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/
    
    0 讨论(0)
  • 2020-12-22 19:50

    Simple do it this on the terminal:

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

    That is where my Sublime is stored, try to type the path to Sublime because your version may differ.

    subl . 
    

    Should be working fine.

    0 讨论(0)
  • 2020-12-22 19:53

    following works with me. I have Sublime version 3 and posting it here if someone is looking for help:

    sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /bin/subl
    
    0 讨论(0)
  • 2020-12-22 19:55
    echo $PATH
    

    and use one of the path already in there. In this example "/usr/local/bin"

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

    if the system return 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
    

    test if it's working

    subl
    

    This is for Sublime Text 3.

    0 讨论(0)
提交回复
热议问题