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.
Written by Nick Kugaevsky
Related protips
2 Responses
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/
@jameswyse OR just copy it to /usr/local/bin
(assuming here that /usr/local/bin
is already in the PATH because of Homebrew).