LoginSignup
6
6

More than 5 years have passed since last update.

OS XでIntelliJ系IDEにターミナルで開くメニューを追加する

Posted at

Android StudioなどIntelliJ系IDEでSublime Text 2のTerminalプラグインである Open Terminal Here… を使いたくなったのでやってみました。

terminal.sh を Sublime Text 2のTerminalプラグインから拝借します。以下の内容をホームディレクトリなど適当な場所に保存してください。 chmod u+x terminal.sh で実行権限も付与。

terminal.sh
#!/bin/bash

CD_CMD="cd "\\\"$(pwd)\\\"" && clear"
VERSION=$(sw_vers -productVersion)
if (( $(expr $VERSION '<' 10.7.0) )); then
  IN_WINDOW="in window 1"
fi
osascript<<END
try
  tell application "System Events"
    if (count(processes whose name is "Terminal")) is 0 then
      tell application "Terminal"
        activate
        do script "$CD_CMD" $IN_WINDOW
      end tell
    else
      tell application "Terminal"
        activate
        do script "$CD_CMD"
      end tell
    end if
  end tell
end try
END

Preference > External Tools から以下のように追加します

名前
Name Open Terminal Here…
Group Terminal
Description Open Terminal Here
Synchronize files after execution チェック外す
Open console チェック外す
Showin Project viewsのみチェック
Program 借したterminal.sh
Working directory $FileDir$

2013-08-18_0244.png

これでプロジェクトビューの右クリックメニューから実行できます。

6
6
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
6
6