How to add Git Bash to Windows Terminal Application

How to add Git Bash to Windows Terminal Application 1

In this blog post, we will learn how to install Git-SCM and add Git Bash to Windows Terminal profile. If you are completely new to Windows Terminal, then I would highly recommend you to go through the introductory post of installing and understanding Windows Terminal. At the time of writing the current version of Windows Terminal is 1.0

Windows Terminal is a modern terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and Windows Subsystem for Linux (WSL). Its main features include multiple tabs, panes, Unicode and UTF-8 character support, a GPU accelerated text rendering engine, and the ability to create your own themes and customize text, colors, backgrounds, and shortcut key bindings“. [source: Microsoft Docs]

Prerequisite

Install Git-SCM

If Git is already installed on the machine, then this step can be completely be skipped and you can move directly to the next section. Add Git Bash to WindowTerminal profile.

Download Git-SCM

First, we will download and install the Git-SCM from the following link https://git-scm.com/downloads. Here we are using Window Terminal so we will download Git-SCM for Windows and at the time of writing the current version of Git-SCM is 2.27.0

Add Git Bash to Windows Terminal - Download Git-SCM
Add Git Bash to Windows Terminal – Download Git-SCM for Windows

Install Git-SCM

After downloading, we will start the installation process, here while installing we will keep everything as default and install the Git-SCM.

add Git Bash to Windows Terminal - Install Git
Add Git Bash to Windows Terminal – Install Git-SCM

Verify Installation

The installation process will create a git directory inside the %programfiles% folder.

Add Git Bash to Windows Terminal Git Directory
Git Installation Directory

Next, to verify the installation, let us run the git –version command in the terminal. This step assumes the Git path is not yet configured in the Environment variable and it is not required as we are going to point to the bash.exe in the terminal profile.

First, we will open the terminal application and then open the Git’s bin directory, [on my machine, it is C:\Program Files\Git\bin], and executes the command. On successful execution, this will display the git version installed on the machine.

add Git Bash to Windows Terminal Git Version Check
Git version check

Now we are ready to add the git-bash to Window Terminal Profile, so we will move to the next step.

Add Git Bash to Windows Terminal Profile

Now we have Git-SCM installed on our machine, the next step is to add its bash.exe in a new Windows Terminal profile, for this, we will perform the following step.

Add New Profile in settings.json

The first step is to open the settings.json file, and then add a new profile into the profiles list. To open the settings.json file user the “Ctrl + ,” shortcut, or select the Settings menu item from the drop-down. The settings.json file will be opened in your configured JSON editor.

Add Git Bash to Windows Terminal Open Settings.json
Open Settings.json

Now, we will add the following JSON into the profiles list. This is the minimum JSON required to add the profile. Later we will add new value to add further customization configurations. The below code practically does nothing, and we need to provide proper values to every JSON key.

 
{
     // Git-Bash profile
    "guid": "{NEW GUID}",
    "name": "profile-name",
    "commandline": "PATH TO BASH.exe"
},

Configure Key-Value for Profile

Here we provide proper values to each of the key’s in the profile object.

Configure GUID: We require a unique GUID value, for this, we will use the online tool to get a new GUID and paste the same inside the curly braces. When I generated the GUID I got the following value, so my key-value looks like this.

“guid”: “{3b433b11-c393-47ed-9421-bafebb058f6c}”

Configure Name: We can choose any name as per our choice, this is the name of the profile. I will pick Git-Bash as my profile name.

“name”: “Git-Bash”

Configure Bash Path: In the commandline key, we will provide the path of bash.exe. For me, the path for bash.exe is C:\Program Files\Git\bin\bash.exe, so the key-value looks like this. Please note the escape the backslash in the path.

“commandline”: “C:\\Program Files\\Git\\bin\\bash.exe”

So the complete JSON for our new Git-Bash profile looks like this. Save the settings.json file.

{
     // Git-Bash profile
    "guid": "{3b433b11-c393-47ed-9421-bafebb058f6c}",
    "name": "Git-Bash",
    "commandline": "C:\\Program Files\\Git\\bin\\bash.exe"
},

Execute the Git-Bash Profile

Open the Git-Bash profile the drop-down list.

Add Git Bash to Windows Terminal new Profile
Git-Bash Profile Added to Drop-Down Menu
Add Git Bash to Windows Terminal Executing Git Bash
Successfully execution of Git-Bash in Windows Terminal

Optional Configurations

Add Icon

Let us download the git-icon from the Git-SCM official page. Now the next thing is to add the following JSON string. This will add the icon on the profile tab as well as in the profile list in the drop-down menu.

“icon”: “C:\\git-icon.png”

Add Git Bash to Windows Terminal Add icon
Git icon added

Change Cursor Shape and Color

Let us change the cursor shape to filledBox and its color to yellow, for this we are going to add the following to key-value pair to the profile.

“cursorShape”: “filledBox”,
“cursorColor”: “#FFFF00”

Add Git Bash to Windows Terminal Change Cursor
Filled Box Yellow Color Cursor

The complete JSON for the Git-Bash is as follows:

{
        "guid": "{3b433b11-c393-47ed-9421-bafebb058f6c}",      
        "name": "Git-Bash",
        "commandline": "C:\\Program Files\\Git\\bin\\bash.exe",
        "icon": "C:\\git-icon.png",
        "cursorShape": "filledBox",
        "cursorColor": "#FFFF00"
} 

Window Terminal can be customized as per your need, the terminal allows you to customize its color, background image, themes, cursor, tabs, panes, etc. If you want to customize further you can have a look at How to customize Windows Terminal Application post. All in all, it a great tool to manage different shells all in one place.

I hope you find the post on how to add Git Bash to Windows Terminal helpful. Thanks for visiting, Cheers!!!

[ Further ReadsHow to customize Windows Terminal Key Bindings |  How to install Window Terminal in Windows 10 |  Important Debugging Shortcuts of Visual Studio 2019  |  How to publish a Blazor Server Application to IIS  |  Top 7 Visual Studio 2019 extensions for Web Projects  |  The difference in Blazor Server and WebAssembly Application  |  Exploring Blazor WebAssembly App Project Structure |  Top 10 Productivity Tips and Tricks in Visual Studio 2019  |  CRUD Operations in WPF using EntityFrameworkCore and SQLite  | Top Features of Visual Studio 2019 Community Edition  ]

0 0 vote
Article Rating
Subscribe
Notify of
guest
2 Comments
oldest
newest most voted
Inline Feedbacks
View all comments