4

I recently installed a new instance of VS Code on my Mac and the integrated terminal no longer shows the current branch.

In the old world, it would show which branch I was on right now with git and update as I changed branches.

Now, it shows my location in the file directory and git works as normal but it doesn't show the branch.

I have no extensions except for GitHistory. This is an excerpt from my settings file:

{
    "workbench.statusBar.visible": false,
    "explorer.decorations.colors": false,
    "window.zoomLevel": 0,
    "workbench.startupEditor": "newUntitledFile",
    "workbench.editor.closeOnFileDelete": true,
    "workbench.editor.limit.enabled": true,
    "workbench.editor.openPositioning": "first",
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true,
    "terminal.integrated.scrollback": 50000,
    "terminal.integrated.shell.osx": ""
}
3
  • 1
    The update may have switched your integrated terminal shell from Git Bash to Powershell . You can check that in menu File > Preferences > Shell. – harrymc Jul 16 '20 at 12:54
  • Added the shell settings. It looks like it's not set to anything – Cauder Jul 16 '20 at 12:58
  • In Windows you would add "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe". I don't know the Mac equivalence. – harrymc Jul 16 '20 at 13:13
1

The problem is not VS code because you're actually looking at your terminal.

You simply have to edit the settings that define how your terminal appears.

If you're on MacOS Catalina, then you can edit the ~/.zshrc file.

This should be the code that you need-

parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF=$'\e[0m'
COLOR_USR=$'\e[38;5;243m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
NEWLINE=$'\n'
setopt PROMPT_SUBST
export PROMPT='${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}%% '

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.