BashMac
BashMac

Reputation: 41

How to confiure Git Bash on VSC MacOS

How do you add the Git Bash terminal to Visual Studio Code in MacOS?

I am not able to see the "Configure Default Shell" option.

Upvotes: 3

Views: 9344

Answers (2)

d2n
d2n

Reputation: 129

On MacOS, you can use the built-in VSCode terminal which supports bash, and edit your .bash_profile file to show the current branch in the terminal window, left of the cursor.

  1. Open MacOS terminal

  2. Navigate to your home directory:

    cd ~

  3. Open or create the .bash_profile file using a text editor:

    nano .bash_profile

  4. Add the following lines to customise your PS1 environment variable:

    parse_git_branch() {
    
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'}
    
    export PS1="\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[36m\]\$(parse_git_branch)\[\e[0m\] $ "
    
  5. Save the changes and exit the text editor.

  6. Restart your VSCode integrated terminal, and it should now display the current Git branch in the prompt.

Upvotes: 0

villevillekulla
villevillekulla

Reputation: 66

Git bash is a program that ports bash along with some command line tools for use on Windows. Bash is currently the default shell on mac so you don't need to install it in any way. If it is some tool missing that came with Git Bash you can search for install <tool> on mac into Google and find a guide.

If you don't want to use the same shell in VSCode as standard on your machine you can specify it by adding "terminal.integrated.profiles.osx": "<shell>", to your settings.json (Can be found by clicking the {} icon up to to right in settings"). <shell>can be one of the specified shells that is displayed when running cat /etc/shells.

Upvotes: 3

Related Questions