ud775 »

Setting up Sublime

If you don’t have a text/code editor that you like yet, Sublime is a good option that will work on Windows, Mac, and Linux.  You can download Sublime here.

If you go this route, be sure to set up launching Sublime from the command line.  How you do this will differ based on your OS.

Launching Sublime from command-line

Windows

  1. Find the directory where Sublime is located for you.  For many people, this is C:/Program\ Files/Sublime\ Text\ 2/sublime_text.exe.  To test this, run dir "C:/Program\ Files/Sublime\ Text\ 2" within Git Bash.  You should see sublime_text.exe listed.  If you get the error No such file or directory, Sublime is located somewhere else for you and you'll need to find it.  For example, it might be under C:/Program\ Files\ \(x86\).

  2. Run the following command in Git Bash: echo 'alias subl="C:/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"' >> ~/.bashrc If Sublime was in a different directory for you in step 1, use that directory.

  3. Close and re-open Git Bash. 

  4. Type subl in Git Bash. If Sublime opens no further steps are required. If Sublime does not open continue with steps 5 - 7.

  5. Test .bashrc by running the command source ~/.bashrc in Git Bash and retry typing subl to start sublime. If Sublime doesn't start check the contents of the file ~/.bashrc created in step 2.

  6. To ensure the .bashrc file contents is loaded each time you open Git Bash, edit ~/.bash_profile and add the following two lines. (Reference)

    if [ -r ~/.profile ]; then . ~/.profile; fi

    case "$-" in *i*) if [ -r ~/.bashrc ]; then . ~/.bashrc; fi;; esac

  7. Close and re-open Git Bash. Type subl in Git Bash to check it starts correctly.

Mac

  1. Find where the subl command is located.
    subl comes with Sublime, so it should be in the directory where Sublime is located for you.  For many people, this is /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin.  To test this, run ls /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin.  You should see the subl command listed.  If you get the error No such file or directory, Sublime is located somewhere else for you and you'll need to find it.

If you are using Sublime v3, it may be located here: /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/

  1. If you do not have a file named .bash_profile in your home directory, create it.  Because the name of this file begins with a period, it will not appear in most file navigators or when you run ls.  Instead, run ls -a to see if you have the file.

  2. Add the line export PATH=$PATH:/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin to the end of your .bash_profile.  If subl was in a different directory for you in step 1, use that directory.

  3. Close and re-open your terminal.  Typing subl in the terminal should now open Sublime.

Alternatively, you can create a symbolic link to Sublime.

  1. Find where the subl command is located.
    subl comes with Sublime, so it should be in the directory where Sublime is located for you.  For many people, this is /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin.  To test this, run ls /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin.  You should see the subl command listed.  If you get the error No such file or directory, Sublime is located somewhere else for you and you'll need to find it.

  2. If you do not have a file named .bash_profile in your home directory, create it.  Because the name of this file begins with a period, it will not appear in most file navigators or when you run ls.  Instead, run ls -a to see if you have the file.

  3. Add the lines export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH and export EDITOR='subl -w' to the end of your .bash_profile. 

  4. Save and exit .bash_profile.

  5. At the terminal command prompt type: source ~/.bash_profile

  6. At the terminal command prompt type: sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl Note that if subl was in a different directory for you in step 1, use the path to that directory. If prompted for a password, use the same password you use to log into your Mac account.

  7. Close and re-open your terminal.  Typing subl in the terminal should now open Sublime.

Ubuntu

Follow these instructions.

Or Open Terminal and

For Sublime-Text-2: sudo add-apt-repository ppa:webupd8team/sublime-text-2 && sudo apt-get update && sudo apt-get install sublime-text

For Sublime-Text-3: sudo add-apt-repository ppa:webupd8team/sublime-text-3 && sudo apt-get update && sudo apt-get install sublime-text-installer

Once you have Sublime Text installed you can launch it from the terminal with: subl or sublime-text