Skip to content

Instantly share code, notes, and snippets.

@wanybae
Last active March 25, 2017 03:36
Show Gist options
  • Save wanybae/4334130 to your computer and use it in GitHub Desktop.
Save wanybae/4334130 to your computer and use it in GitHub Desktop.
Mac OS X의 터미널에서 Sublime Text 2를 실행하기

Mac OS X 터미널에서 Sublime Text 2 실행하기

Sublime Text 2는 subl(왜 sublime이 아닌지는 의문)이라는 CLI(Command-lime interface)을 갖고있다. 이 유틸리티는 디폴트로 설치되는 다음과 같은 폴더에 위치한다.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

설치

물론 저 폴더에 있는 subl을 바로 사용하면 되겠지만 편리하게 사용할 수 있는 두가지 방법을 적어본다.

심볼릭 링크 사용

Sublime팀에서는 홈디렉토리에 있는 bin폴더에는 아주 많은 바이너리들이 있기때문인지 /usr/local/bin에 화일을 생성시키는 것을 추천하지 않는다고 한다. 그래서 심볼릭 링크를 사용하여 사용을 하도록 한다.

sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

이렇게 sublime이라는 이름으로 심볼릭 링크를 만들어 놓으면 터미널에서 실행이 가능하다. 물론 /usr/local/bin 디렉토리가 PATH에 포함되어 있다는 전재하에서...

open ~/.bash_profile

만약 PATH에 /usr/local/bin디렉토리가 포함되어 있지 않다면 .bash_profile을 열어서 다음과 같이 추가를 해주자.

export PATH=/usr/local/bin:$PATH

마지막의 $PATH는 이전 PATH에 지정해 놓은 값이 있을경우를 대비하여 저렇게 붙혀준 것이다. 이렇게 작성하고 저장한뒤

source ~/.bash_profile

.bash_profile을 리로드 시켜주면 변경내용이 반영될 것이다.

alias를 사용

위와 같이 동일하게 .bash_profile을 열어서 다음과 같은 alias를 만들어두는 것도 한 방법이 된다.

alias sublime='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'

테스트

터미널을 열어서 다음과 같이 사용해보자

sublime filename // 지정한 화일을 연다.
sublime foldername // 지정한 폴더를 연다.
sublime . // 현제 폴더를 연다.
@not-for-me
Copy link

덕분에 잘 쓰고 있습니다. 감사합니다. ^^

@wanybae
Copy link
Author

wanybae commented Jun 4, 2014

@jwj0831 아, 참고하셨다니 다행이네요. ^^;

@garyGitgit
Copy link

감사합니다 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment