解决 IDEA 下的 Terminal 中文乱码的方法
terminal
The new Windows Terminal and the original Windows console host, all in the same place!
项目地址:https://gitcode.com/gh_mirrors/term/terminal

·
在使用 IDEA 进行开发的时候,经常会用到 Git 进行代码管理,如果再开一个 git bash窗口的话,窗口切换来切换去的很不方便
为了简单方便,我们可以直接在 IDEA 中使用自带的 Terminal,这样就可以达到在 IDEA 主界面敲代码,侧边栏敲 Git 命令的效果
但是自带的 Terminal 默认的配置是 Cmd 窗口,直接使用 Git 命令会对中文进行 Unicode 转码,也就是所谓的乱码
这里简单的介绍下具体的配置流程以及使用 Git 命令会引起的中文 Unicode 编码的解决方法
将 IDEA Terminal 命令窗口修改为 Git bash 命令窗口
1、打开 settings 设置界面,选择 Tools 中的 Terminal (File -> settings -> Tools -> Terminal)
2、修改 Shell path 为你的 Git bash 安装路径,我的在C:\Program Files\Git\bin\bash.exe
3、重新打开你的 Terminal 就能看到变成了经常看到的 Git bash 窗口
解决中文 Unicode 编码问题
以上的步骤就将默认的 Cmd 窗口换成了 Git bash 窗口,但是中文依旧会自动转换为 Unicode 编码
修改 Git 的安装目录etc下的bash.bashrc文件,我的目录是:C:\Program Files\Git\etc,在该文件最后添加以下代码
#解决IDEA下的terminal中文Unicode编码问题
export LANG="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"
注意:可能需要管理员权限打开才能编辑
添加以后重启 IDEA,重新打开 Terminal 查看中文内容,就成功显示中文啦




The new Windows Terminal and the original Windows console host, all in the same place!
最近提交(Master分支:6 个月前 )
b8ff95d6
- Remove duplicated entries.
- Fix whitespace.
Co-authored-by: João Guerra <joca-bt@users.noreply.github.com> 28 天前
f28f6587
1 个月前
更多推荐
所有评论(0)