一次解决Mac终端中文乱码问题

使用oh-my-zsh查看中文目录显示乱码

描述

  • 在使用ls指令查看目录时,对于中文目录会显示乱码
  • 原因是locale没有设置成utf-8

解决方法

	终端输入:
	vi ~/.zshrc
	在文件末尾添加:
	export LC_ALL=en_US.UTF-8  
	export LANG=en_US.UTF-8
	最后重启终端

使用git status中文文件显示乱码

描述

  • 对于上传的中文文件显示乱码
  • core.quotepath没有设置好

解决方法

	终端输入:
	git config --global core.quotepath false

参考文章

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
VSCode (Visual Studio Code) 中文显示乱码终端通常是由于编码设置不匹配造成的。以下是解决步骤: 1. **检查默认编码**:确保终端的默认字符编码是UTF-8。可以在终端设置里查找`"terminal.integrated.shell.windows"`(Windows)或`"terminal.integrated.shell.linux"`(Linux/Mac)的值,设置成合适的路径加上`-utf8`,比如`"/bin/bash -utf8"`。 2. **设置终端配置**:打开终端控制台,输入 `echo $TERM` 查看当前终端类型,然后在用户设置(`Settings.json`)或工作区设置(`Workspace Settings.json`)中添加相应的配置项。例如,对`xterm`终端,可以增加如下配置: ```json "terminal.integrated.encoding": "UTF-8" ``` 或者针对特定终端类型设置: ```json { "terminal.integrated.defaultFontFamily": "Consolas", "terminal.integrated.fontLigatures": false, "terminal.integrated.fontSize": 14, "terminal.integrated.lineHeight": 1.5, // 针对 xterm 终端 "terminal.integrated.cursorStyle": "block", "terminal.integrated.tabs.showOnLineNumbers": true, "terminal.integrated.rendererType": "dom", "terminal.integrated.shellArgs.windows": ["cmd", "/u", "/c"], "terminal.integrated.shellArgs.linux": ["xterm", "-encoding", "UTF-8"], "terminal.integrated.shellArgs.osx": ["-e", "TERM=screen-256color"] } ``` 3. **重启终端**:更改设置后,记得关闭并重新打开终端窗口,让新的设置生效。 如果你已经尝试了以上步骤仍然有乱码,可能是你的系统环境变量或者某些特殊程序需要单独处理。你可以检查你的系统编码设置,以及文件和目录的编码一致性。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值