Terminal から Sublime Text を起動できるようにする
概要
- Git を扱うようになってから、CUI での操作が増えた
 open .で Finder が開くように、コマンド入力で指定したファイルを Sublime Text で開くといった動作をしたくなった- できそうなので設定をしてみる
 
公式リファレンス
Command Line Interface
To use subl, the Sublime Text bin folder needs to be added to the path. For a typical installation of Sublime Text, this will be located at /Applications/Sublime Text.app/Contents/SharedSupport/bin.
パスを通してあげれば subl  というコマンドが使えるようになるらしい。
作業ログ
パスを通す
- 
Terminal を起動
 - 
前述の公式リファレンスに記載されている ZSH 用のコマンドを実行する
> echo 'export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"' >> ~/.zprofile - 
.zprofileを読み込みなおす(もしくは Terminal を再起動/一度閉じて開き直す)> source .zprofile 
subl コマンドを試す
Terminal 上で適当にディレクトリとファイルを作成
> mkdir subl-test
> cd subl-test
> touch index.html
作成したファイル(ここでは index.html )を開くコマンドを実行
> subl index.html
結果、Sublime Text が立ち上がり、該当ファイルが開かれた。成功!
使い方を確認しておく
以下のコマンドで使い方を確認できる。
> subl --help
表示される内容は以下。1行目には本体のバージョン番号が出力される。
Sublime Text build 4169
Usage: subl [arguments] [files]         Edit the given files
   or: subl [arguments] [directories]   Open the given directories
   or: subl [arguments] -- [files]      Edit files that may start with '-'
   or: subl [arguments] -               Edit stdin
   or: subl [arguments] - >out          Edit stdin and write the edit to stdout
Arguments:
  --project <project>:    Load the given project
  --command <command>:    Run the given command
  -n or --new-window:     Open a new window
  --launch-or-new-window: Only open a new window if the application is open
  -a or --add:            Add folders to the current window
  -w or --wait:           Wait for the files to be closed before returning
  -b or --background:     Don't activate the application
  -s or --stay:           Keep the application activated after closing the file
  --safe-mode:            Launch using a sandboxed (clean) environment
  -h or --help:           Show help (this message) and exit
  -v or --version:        Show version and exit
--wait is implied if reading from stdin. Use --stay to not switch back
to the terminal when a file is closed (only relevant if waiting for a file).
Filenames may be given a :line or :line:column suffix to open at a specific
location.