LoginSignup
1
0

More than 1 year has passed since last update.

Cygwin bash を Windows Terminal や Visual Studio Codeで使うプロファイル

Last updated at Posted at 2021-04-19

Windows Terminalのsettings.jsonへの設定

"commandline": "C:\\cygwin64\\bin\\env.exe CHERE_INVOKING=t /bin/bash --login -i",
"icon": "C:\\cygwin64\\Cygwin-Terminal.ico",
"startingDirectory": "%HOME%"

"name""hidden"はお好みで。

bashのオプション --login は、bashをログインシェルとして起動させる。そうしないと /etc/profile が実行されず、環境変数 PATH などがセットされない。

オプション -i は、起動するbashを対話的なシェルとする。

bashを直接起動せず、envを使ってCHERE_INVOKINGをセットした上でbashを起動するのは、/etc/profile でカレントディレクトリが ${HOME} にされてしまうのを防ぐため。

この設定で、エクスプローラーの右クリックメニュー「Open in Windows Terminal」で起動すると、そのフォルダでbashが起動する。

"startingDirectory" には、それ以外の場合の初期ディレクトリを設定しておく。

[設定]での表示
image.png

確認バージョン
Windows Terminal バージョン: 1.7.1033.0
BASH_VERSION: 4.4.12(3)-release x86_64-unknown-cygwin

Visual Studio Codeのsettings.jsonへの設定

Visual Studio Code のsettings.jsonの設定も同様でよい。

{
  "terminal.integrated.profiles.windows": {
      "Cygwin bash": {
          "path": "C:\\cygwin64\\bin\\env.exe",
          "args": [
              "CHERE_INVOKING=t",
              "/bin/bash",
              "--login",
              "-i"
          ]
      }
  },
  "terminal.integrated.defaultProfile.windows": "Cygwin bash"
}

参考リンク

Windows ターミナルの全般的プロファイル設定 | Microsoft Docs
Integrated Terminal in Visual Studio Code

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