不建议将iTerm设置为VS Code的集成终端

最初问题出现在 VS Code 某一次更新后…

之前一直将 iTerm 作为 VS Code 的集成终端,此前,已经折腾过 iTerm 了,在 VS Code 某一次更新后,官网里面只有关于 Windows 的 powershell 配置,没有 Mac 的相关配置,后续一直在 VS Code 终端上出现奇怪的报错,比如 not found npm,根本原因终于找到了。Kronos 的原文解释:

iTerm is not a shell but a terminal emulator which in your case is running the zsh shell.

I believe you are confusing the terms Shell and a terminal emulator.

iTerm is a terminal emulator. Some examples of terminal emulator are Gnome terminal, Guake, Xterm etc. They provide a display to the shell which is installed in the OS.

A shell is a command line interface that reads and interprets your commands. Examples of shell are bash which comes by default in Linux and other shells like zsh, fish, sh.

Visual Studio Code integrated terminals use the shell itself and not the terminal emulator. In Windows OS the distinction between shell and terminal emulator is not present so Powershell and Command Prompt are both the shell and the emulator.

But for Unix like OSes there is a distinction.

I believe you use iTerm as the terminal emulator and the shell used is zsh (pronounced Z Shell which is a fork of bash Bourne Again Shell).

Here is a wikipedia article on Unix Shell. This talks about what a Unix shell really is.

This link is about Terminal emulators which also talks about the history of terminals.

This link gives a list of terminal emulators that are available. iTerm is a terminal emulator for Mac OS.

摘要大意就是:

VS Code 集成终端使用 shell 本身,而 Mac OS(类 Unix)上的 iTerm 是一个终端仿真器,而 Windows 中不存在 shell 和终端仿真器,因此, powershell 和命令提示符既是 shell 又是仿真器。

这也正好解释了 VS Code 官网为什么只有 Windows 下的终端配置而没有 Mac 下的终端配置的原因。

至于哪些开发软件只能采用 shell,没必要去纠结判断,结论就是:Mac OS 上开发工具的终端回归默认,可以从根源上避免终端仿真器带来的 bug。

rf.

VS Code官网终端配置文件

不能将iTerm设置为VS Code的集成终端

Unix Shell

终端模拟器

终端模拟器的列表

Change default terminal app in Visual Studio Code on Mac

文章作者: 夜行书生
文章链接: https://yexingshusheng.com/2022/08/bu-jian-yi-jiang-iterm-she-zhi-wei-vs-code-de-ji-cheng-zhong-duan.html
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 夜行书生