Reputation: 41
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
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.
Open MacOS terminal
Navigate to your home directory:
cd ~
Open or create the .bash_profile file using a text editor:
nano .bash_profile
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\] $ "
Save the changes and exit the text editor.
Restart your VSCode integrated terminal, and it should now display the current Git branch in the prompt.
Upvotes: 0
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