Search code examples
bashmacosvisual-studio-codeterminalhomebrew

Update macOS Bash version for VSCode's integrated terminal


After following these instructions to update Bash and set it as my default shell on macOS, I found that it didn't have any effect on the integrated terminal in VSCode. As shown by:

echo $0 which returned /bin/bash instead of /opt/homebrew/bin/bash.

and

echo $BASH_VERSION which returned 3.2.57(1)-release instead of 5.1.12(1)-release(or later).

Applying the same instructions inside VSCode, using sudo on chsh and setting "Terminal > integrated > Default Profile: Osx" to "Bash" all didn't have any effect.

How do I fix this?


Short instructions
  1. Download newest Bash version using Homebrew: brew install bash.

  2. Whitelist updated version (path: /opt/homebrew/bin/bash) to /etc/shells using Vim.

  3. Set as default shell using chsh -s /opt/homebrew/bin/bash.


Solution

  • Simply add the following line to settings.json (which can be found inside settings) to override the original path:

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

    Edit

    After I posted this answer I found out that this method is deprecated.

    The right way to do it is by making a new terminal profile and setting it as your default:

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