LoginSignup
14
15

More than 5 years have passed since last update.

Atom Editor を EDITOR 環境変数に設定する

Last updated at Posted at 2016-03-15

どういう問題?

.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 とは全く意味が違う罠。

14
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
15