iuxapa
Last Updated: February 25, 2016
·
6.832K
· kugaevsky
Ava white

Run Sublime Text unlinked from terminal session in Linux and Darwin

Just add it to your working environment to run Sublime Text 2 from terminal window via short aliases. Works both in Linux (Ubuntu) and Darwin (OS X).

  • $ st filename — opens file in Sublime Text 2
  • $ st dirname — opens directory
  • $ stt — opens current directory

Place this code in your home directory .profile or .zshrc file

if [[ $('uname') == 'Linux' ]]; then
  runst() { nohup /usr/bin/sublime-text-2 $@ > /dev/null & }
  alias st=runst
elif  [[ $('uname') == 'Darwin' ]]; then
  alias st='open -a /Applications/Sublime\ Text\ 2.app'
fi
alias stt='st .'

NB! Running Sublime Text 2 instance do not occupy your terminal session and wouldn't close if you finish console session or close terminal application.

Say Thanks
Respond

2 Responses
Add your response

1627
5d7031cae1f36c2cbbd4b812a24709d9

There's also a subl binary available inside the MacOS Application package:

/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/

You can add this folder to your PATH to make it available everywhere by adding the following line to your .bash_profile file:

export PATH=$PATH:/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/

over 1 year ago ·
1630
 dsc0036

@jameswyse OR just copy it to /usr/local/bin (assuming here that /usr/local/bin is already in the PATH because of Homebrew).

over 1 year ago ·