更新 VSCode 集成终端的 Bash 版本 |苹果操作系统



按照这些说明更新Bash并将其设置为MacOS上的默认shell后,我发现它对VSCode中的集成终端没有任何影响。如图所示:

echo $0返回/bin/bash而不是/opt/homebrew/bin/bash

返回3.2.57(1)-release而不是5.1.12(1)-release(或更晚)的echo $BASH_VERSION

 

在VSCode中应用相同的指令,在chsh上使用sudo并将"终端>集成>默认配置文件:Osx"设置为"Bash"都没有任何效果。

我该如何解决这个问题?

 

<小时 />
简短说明
  1. 使用自制软件下载最新的 Bash 版本:brew install bash

  2. 将更新版本(路径:/opt/homebrew/bin/bash)列入白名单,以使用 Vim 进行/etc/shells

  3. 使用chsh -s /opt/homebrew/bin/bash设置为 默认外壳。

只需将以下行添加到settings.json(可以在设置中找到)即可覆盖原始路径:

// "...",
"terminal.integrated.shell.osx": "/opt/homebrew/bin/bash",
// "...",

编辑

在我发布这个答案后,我发现这种方法已被弃用。

正确的方法是创建一个新的终端配置文件并将其设置为默认值:

// "...",
"terminal.integrated.profiles.osx": {
"new bash": { // profile name
"path": "/opt/homebrew/bin/bash"
}
},
"terminal.integrated.defaultProfile.osx": "new bash",
// "...",

最新更新