makoラボ

日常や勉強会や技術ネタ

git commit時にコメントをSublime Textで書きたい

git commitをした時にSublime Textでコメントを書きたかったので、設定してみたものの動か無かったりしたのでハマった所のメモ。

sublコマンドの登録

公式にそれぞれやり方が書いてあるので参考に登録。

Sublime Text 3

http://www.sublimetext.com/docs/3/osx_command_line.html

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Sublime Text 2

http://www.sublimetext.com/docs/2/osx_command_line.html

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

gitのコミット時のエディタをsublにする

gitの設定を変更します。

git config --global core.editor "subl -w"

なぜかコミット出来ない

これでだいたいのブログとかで書かれている手順は終了なのですがなぜか自分の環境では以下のエラーが出てコミット出来ない・・・

subl -w: subl: command not found
error: There was a problem with the editor 'subl -w'.
Please supply the message using either -m or -F option.

コマンドが見つからない?ちゃんと設定しているはずなのに・・・ と困っていて調べてみると以下の記事が出てきました。 http://stackoverflow.com/questions/10892368/problems-using-subl-command-in-terminal-command-not-found-no-such-file-or どうやらrvm関連でそっちにもシンボリックリンクを貼っておかないとダメみたい。

rvmのbinにsublコマンドを登録

ということなのでrvm配下のbinにシンボリックリンクを貼ります。

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/.rvm/bin/subl

これで無事コミットできるようになりました。