【问题标题】:Update Bash version for VSCode's integrated terminal | MacOS为 VSCode 的集成终端更新 Bash 版本 |苹果系统
【发布时间】:2022-01-08 01:47:19
【问题描述】:

在关注these instructions更新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 中应用相同的指令,在 chsh 上使用 sudo 并将“终端 > 集成 > 默认配置文件:Osx”设置为“Bash”都没有任何效果。

我该如何解决这个问题?

 


简短说明
  1. 使用 Homebrew 下载最新的 Bash 版本:brew install bash

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

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

【问题讨论】:

    标签: bash macos visual-studio-code terminal homebrew


    【解决方案1】:

    只需将以下行添加到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",
    
    // "...",
    

    【讨论】:

      猜你喜欢
      • 2020-02-24
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-11
      • 2019-12-11
      • 2018-09-28
      • 2020-12-08
      • 2020-07-05
      相关资源
      最近更新 更多