按照这些说明更新 Bash 并将其设置为 macOS 上的默认 shell 后,我发现它对 VSCode 中的集成终端没有任何影响。如图所示:
echo $0
返回
/bin/bash
而不是
/opt/homebrew/bin/bash
。
和
echo $BASH_VERSION
返回
3.2.57(1)-release
而不是
5.1.12(1)-release
(或更高版本)。在 VSCode 中应用相同的指令,在
sudo
上使用
chsh
并将“终端 > 集成 > 默认配置文件:Osx”设置为“Bash”,都没有任何效果。我该如何解决这个问题?
brew install bash
。
/opt/homebrew/bin/bash
)更改为
/etc/shells
。
chsh -s /opt/homebrew/bin/bash
设置为默认 shell。
只需将以下行添加到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",
// "...",
brew install bash
安装 bash 和brew。
/opt/homebrew/bin/bash --version
确认安装。
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> .bash_profile
这一步的参考是这个答案。
command + ,
在 VS Code 中打开 设置
。
terminal.integrated.profiles.osx搜索相应的设置,然后单击在settings.json中编辑。
添加新的
bash-5.2
个人资料
"bash-5.2": {
"path": "/opt/homebrew/bin/bash",
"args": [
"-l"
],
"icon": "terminal-bash"
},
注意,上面的 -l
选项告诉 Bash 表现得像一个登录 shell,这将加载我们上面在
eval
中保存的
.bash_profile
步骤。