LoginSignup
1
1

More than 5 years have passed since last update.

Android StudioのTerminalでCygwinを使う

Last updated at Posted at 2018-12-27

はじめに

普段の開発環境はMacなのでいざWindowsで開発するとコマンドプロンプトの違和感がすごい。
そうだAndroid StudioやIntelli JIDEAのTerminalでCygwinを使おう。

元ネタ: How to use cygwin bash in Android Studio terminal and start it at project directory?

環境

  • Windows10
  • Android Studio 3.2
  • Intelli JIDEA 2018.2.7
  • Cygwin

設定

CygwinはC:\cygwin64にインストールされている前提。
Cygwinを起動し.bash_profileに下記を追加。

.bash_profile
if [ -n "${IDE}" ] && [ "${IDE}" == "AndroidStudio" -o "${IDE}" == "IntelliJIDEA" ]; then
  cd -;
fi

C:\cygwin64 に以下のファイルを作成。

Cygwin-IDE.bat
@echo off
set IDE=%1
C:\cygwin64\bin\bash --login -i

AndroidStudioのSettings>Tools>Terminalを開きShell pathを下記に変更。

"cmd" /c "C:\cygwin64\Cygwin-IDE.bat AndroidStudio"

IntelliJIDEAも同様に設定。

"cmd" /c "C:\cygwin64\Cygwin-IDE.bat IntelliJIDEA"

環境変数に引数が渡るので.bash_profileでIDE別に設定をしてもいい。

結果

image.png

備忘

  • Cygwinはデフォルトでgitを入れてくれない。インストール時に含めておく。
  • Cygwinを C:\Program Files\cygwin64 当にインストールすると、そのままだとAndroidStudioがShell Pathに設定したコマンドを実行できない。スペースでオプション扱いになる。

  • 先駆者がいらっしゃった……タイトルまで丸かぶり「IntelliJ IDEAのTerminalをCygwinにする

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