Subl command not working - command not found

前端 未结 13 494
别那么骄傲
别那么骄傲 2021-01-30 05:11

I\'m having difficulty getting this set up. I fixed my .bash_profile, and created the symlink using the following command from the Sublime website:

         


        
相关标签:
13条回答
  • 2021-01-30 05:38

    My similar problem was solved simply by omitting the quotes. So if you're working with:

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

    I instead did:

    ln -s /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl ~/bin/subl
    
    0 讨论(0)
  • 2021-01-30 05:41

    Create the symlink in /usr/local/bin instead of ~/bin and make sure that /usr/local/bin in in PATH.

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

    If you don't find /usr/local/bin/, then add the following lines to your .bashrc or .zshrc:

    PATH=$PATH:/usr/local/bin/; export PATH
    
    0 讨论(0)
  • 2021-01-30 05:41

    At my end subl was working fine but git was unable to access it. And was displaying these errors

    subl -n -w: subl: command not found
    error: There was a problem with the editor 'subl -n -w'.
    

    For Mac OS X in the file ~/.gitconfig under [core] I had to put this code to solve the issue on my end.

    editor = /Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl  -n -w
    
    0 讨论(0)
  • 2021-01-30 05:44

    "Launch Sublime Text from the command line on OSX" worked for me. I use Sublime Text 3 and only had to copy and paste the commands below to the command-line. I did this at the root level

    $ cd ~
    
    • If you're using Sublime Text 3 copy then paste this to the command line:

      // Sublime Text 3
      $ ln -sv "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
      
    • If you're using Sublime Text 2 copy then paste this to the command line:

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

    Now test it out to see if it works:

    1. Open a new file from the command line:

      $  subl test.rb  // it should open new file test.rb in Sublime Text
      
    2. Open a project folder:

      $ subl dir/myProject // opens a new folder inside Sublime
      
    3. Launch Sublime app:

      $ subl // launches Sublime
      

    To open Sublime Help for more detailed options use:

    $ subl -h // Sublime help
    
    0 讨论(0)
  • 2021-01-30 05:44

    I tried several combinations using sudo and also including or excluding leading / and escaping spaces in the Sublime\ Text.app package.

    What worked to create the desired symlink was:

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

    I did not have to use sudo or modify $PATH.

    For reference, I am on Mac OS Mojave 10.14.

    echo $PATH currently (and without any modification by me) shows the following:

    $ echo $PATH
    /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
    

    You can tell if this worked by typing which subl immediately after running the ln command above. If you don't get a line of output showing you where Bash found your subl command then you don't have it.

    0 讨论(0)
  • 2021-01-30 05:50

    You could just add the following to the shell config file .bash_profile or .zshrc (Apple replaced bash with zsh as the default shell in macOS Catalina):

    alias subl="open -a /Applications/Sublime\ Text.app" 
    

    These are the steps to edit .zshrc and save the changes (press ESC and :wq! to save and exit):

    $ cd ~
    $ vim .zshrc
    $ source .zshrc
    

    To verify that it works, try the following and it should open up Sublime Text.

    $ subl .zshrc
    
    0 讨论(0)
提交回复
热议问题