fabiospampinato / vscode-terminals

An extension for setting-up multiple terminals at once, or just running some commands.
MIT License
121 stars 19 forks source link

Git branch in prompt out of sync #52

Open sbungert-mms opened 3 years ago

sbungert-mms commented 3 years ago

Hi.

This is my termnals config

{
  "autorun": false,
  "autokill": true,
  "terminals": [
    {
      "name": "MonoRepo",
      "description": "Starts the MonoRepo dev server",
      "cwd": "/Users/path/to/folder/3",
      "open": false,
      "focus": true
    },
    {
      "name": "MonoRepo 2",
      "description": "Use for installing packages or doing other things to the MonoRepo",
      "cwd": "/Users/path/to/folder/3",
      "open": false,
      "focus": false
    },
    {
      "name": "PWA",
      "description": "PWA App",
      "cwd": "/Users/path/to/folder/2",
      "open": false,
      "focus": false
    },
    {
      "name": "PWA tests",
      "description": "Run tests on the PWA App",
      "cwd": "/Users/path/to/folder/2",
      "open": false,
      "focus": false
    },
    {
      "name": "COMP",
      "description": "Shared Components lib",
      "cwd": "/Users/path/to/folder/1",
      "open": false,
      "focus": false
    },
    {
      "name": "COMP Tests",
      "description": "Run tests on the Shared Components lib",
      "cwd": "/Users/path/to/folder/1",
      "open": false,
      "focus": false
    },
    {
      "name": "COMP SB",
      "description": "Shared Components lib Storybook",
      "cwd": "/Users/path/to/folder/1",
      "open": false,
      "focus": false
    }
  ]
}

And i have the following in my .bash_profile

###############################
# Show git branch in terminal #
###############################

function gitBranch() {
    GIT_BRANCH="$(git branch 2>/dev/null | grep '^*' | colrm 1 2)"

    if [ -n "$GIT_BRANCH" ]; then
        echo "($GIT_BRANCH)"
    fi
}

PS1='\[\e[0;1;38;5;70m\]\u:\[\e[m\] \[\e[0;1;38;5;32m\]\w\[\e[m\] \[\e[0;1;38;5;167m\]$(gitBranch)\[\e[m\] \[\e[0m\]\$\[\e[m\] \[\e0'

Any terminals made with the terminals manager do not update the git branch if I change the branch via VSCode's statusbar. If I change the branch via terminal, VSCode's status bar does not update.

This behaviour does not occur if I create a terminal with the new terminal button native to VSCode. Is there something I can add to my terminals settings to keep the branch up-to-date?

Mac OS Catalina VSCode 1.53.2 Terminals Manager 1.12.9

This does not occur on Ubuntu.

fabiospampinato commented 3 years ago

I'm not sure how this issue could be related to the extension, perhaps the extension should set different environment variables or something 🤔