どういう問題?
.bashrc や .zshrc などで EDITOR 環境変数に Atom Editor を設定するときのお話。
そのまま export EDITOR=atom とすると Atom が起動してすぐに shell に戻ってしまう。(正確には Atom を起動する shell script がすぐに正常終了してしまう)
そこで export EDITOR='atom -nw' ですよ
export EDITOR='atom -nw' とすると Atom が新規ウィンドウで開かれて、その新規ウィンドウが閉じられるまで待機するようになる。
これで shell で git commit したときに Atom が起動し、コミットコメント記載して Cmd+S Cmd+w Cmd+w できてハッピー。
具体的には
.zshrc
if [[ -x `whence -p atom` ]]; then
export EDITOR='atom -nw'
elif [[ -x `whence -p emacs` ]]; then
export EDITOR=emacs
else
export EDITOR=vi
fi
こんな感じで設定しています。
-nw の意味
$ atom -h
の結果から一部抜粋
| option | 説明 |
|---|---|
| -n, --new-window | Open a new window. |
| -w, --wait | Wait for window to be closed before returning. |
Emacs -nw とは全く意味が違う罠。