vscode shellArgs.windows参数如何设置使得powershell终端字符集编码为UTF-8?

网上的大部分是这个答案:

"terminal.integrated.shellArgs.windows": ["-NoExit", "/c", "chcp 65001"]

如果你觉得不行,请用这个

"terminal.integrated.shellArgs.windows": ["chcp 65001", ";", "powershell", "-NoLogo"]

下面解释原因

而且里面需要用到 "type": "shell" ,那么他们是不兼容的,会显示这个 参数格式不正确 - -Command ,我当时的感觉是 搞死人了。

先解释下这个报错,你加了上面那个 shellArgs后会自动带上一个 -Command -

然后执行 tasks"type": "shell"时又会自动带上 -Command

最终的命令变成了 powershell chcp 65001 -Command – -Command “你的命令”

所以提示 参数格式不正确 - -Command

附:看 powershell可用参数 powershell -?

补充一个简化版:

“terminal.integrated.shellArgs.windows”: [“chcp 65001; powershell -NoLogo”]

VSCode的设置更新了,我跟进一版最新的

“terminal.integrated.profiles.windows”: {
“powershell”: {
“source”: “PowerShell”,
“args”: [“chcp 65001; powershell -NoLogo”]
}
},
“terminal.integrated.defaultProfile.windows”: “powershell”,

Original: https://www.cnblogs.com/Recco/p/16168693.html
Author: Recco_Do
Title: vscode shellArgs.windows参数如何设置使得powershell终端字符集编码为UTF-8?

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/607098/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球