5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VisualStudioCode 統合コンソール のbash.exe でファイル名の日本語文字化け対応

Posted at

VSCodeの統合コンソールで cmd じゃなくて Bashを使いながら作業をしたい!と思ったけど、ls したときに Windowsのディレクトリ名などの表示で日本語が化けてハマったのでメモ。

やりたいこと

  • VisualStudioCode の統合コンソールでBashを使いたい
  • bash on windowsだとそのまま Windows の exe を実行できなくてデバッグが面倒だったので今回は git for windows に同梱のbash.exe を使う。 https://git-for-windows.github.io/
  • ディレクトリ名やファイル名の日本語が化けるので対策したい

手元の環境

  • Windows10
  • VisualStdioCode 1.9.1
  • git for windows のインストール先が "C:\Program Files\Git"

統合コンソールで使うシェルの設定

  • VScode のメニューから ファイル → 基本設定 → 設定でユーザ設定に下記を1行追加
   "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  • 設定を保存、VScodeを再起動。
  • Ctrl+` で起動する統合コンソールで指定した bash.exe が起動するようになる。
  • ls などで文字化けるか確認する
  • locale の状態を見ると 日本語設定がない事を確認できるので確認する

bashrc の設定追加

  • bash.exe が起動時に見る %home%/.bashrc へ下記を追記
export LC_ALL=ja_JP.utf8
export LANG=ja_JP.utf8
export LANGUAGE=ja_JP.utf8
export LC_CTYPE="ja_JP.utf8"
export LC_NUMERIC="ja_JP.utf8"
export LC_TIME="ja_JP.utf8"
export LC_COLLATE="ja_JP.utf8"
export LC_MONETARY="ja_JP.utf8"
export LC_MESSAGES="ja_JP.utf8"
  • VScode の統合コンソールを再起動して locale の状態、ls で文字化けが解消したかを見る

今回参考にしたサイトなど

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?