Search code examples
bashgitvisual-studio-codewindows-subsystem-for-linux

How do I show up the current branch in WSL ( I use Vscode)


I use Vscode, and I want to know Where my HEAD is pointing branch,
How Can I show up the current branch name like Bash?
I use WSL(ubuntu)termimal in my Vscode and OS is Windows 10

Thank you

WSL image


Solution

  • Note that, from microsoft/vscode issue 67670, the current branch name is already visible in the status bar of VSCode.

    branch VSCode

    Or, with Git 2.22+ (Q2 2019)

    git branch --show-current
    

    It is true the prompt in a git bash in VSCode does not display the Git branch.

    You need to configure the $SHELL

    For example, to enable running bash as a login shell (which runs .bash_profile), pass in the -l argument (with double quotes):

    // Linux
    "terminal.integrated.shellArgs.linux": ["-l"]
    

    Then in your ~/.bashrc can include a special prompt.