Love your Sublime and want to use it to open files right from the terminal? Follow the steps below. Better yet, it helps you set 'subl' as your shortcut, punch in subl <filename> to open text / code files with sublime right from the command line. Save you a few words of typing too - somewhat important for a lot of developers.
Launching Sublime from command-line
source: udacity learning wiki! Not written by me. I just need it so often, I am keeping the entire notes here.Windows
- 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, runls C:/Program\ Files/Sublime\ Text\ 2
within Git Bash. You should seesublime_text.exe
listed. If you get the errorNo 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)`. - Run the following command in Git Bash:
echo 'alias subl="C:/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"' >> ~/.bashrc
Ifsubl
was in a different directory for you in step 1, use that directory. - Close and re-open Git Bash. Typing
subl
in Git Bash should now open Sublime.
Mac
- 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, runls /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin
. You should see thesubl
command listed. If you get the errorNo such file or directory
, Sublime is located somewhere else for you and you'll need to find it. - 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 runls
. Instead, runls -a
to see if you have the file. - Add the line
export PATH=$PATH:/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin
to the end of your .bash_profile. Ifsubl
was in a different directory for you in step 1, use that directory. - Close and re-open your terminal. Typing
subl
in the terminal should now open Sublime.
Alternatively, you can create a symbolic link to Sublime.
- 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, runls /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin
. You should see thesubl
command listed. If you get the errorNo such file or directory
, Sublime is located somewhere else for you and you'll need to find it. - 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 runls
. Instead, runls -a
to see if you have the file. - Add the lines
export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH
andexport EDITOR='subl -w'
to the end of your .bash_profile. - Save and exit .bash_profile.
- At the terminal command prompt type:
source ~/.bash_profile
- At the terminal command prompt type:
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/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. - Close and re-open your terminal. Typing
subl
in the terminal should now open Sublime.
No comments:
Post a Comment