Add git bash profile to windows terminal что это

The post discusses how to install Git-SCM and add Git Bash to Windows Terminal profile as well as how to apply some basic customizations to the profile.

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

  • Window Terminal – Should be installed [How to install Windows Terminal]

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 FilesGitbin], 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.

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 FilesGitbinbash.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 and place the icon inside the installation folder (C:\Program Files\Git\mingw64\share\git\). 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:\Program Files\Git\mingw64\share\git\git-for-windows.ico”

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”

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 Readings: How to customize Windows Terminal Application |  How to customize Windows Terminal Key Bindings |  How to Install Windows 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 |  How to implement Dependency Injection in WPF |  How to use External Tool in Visual Studio 2019  ]  

title description author ms.author ms.date ms.topic

Windows Terminal Dynamic Profiles

Learn about dynamic profiles in Windows Terminal.

cinnamon-msft

cinnamon

01/06/2022

conceptual

Dynamic profiles in Windows Terminal

Windows Terminal will automatically create Windows Subsystem for Linux (WSL) and PowerShell profiles for you if you have these shells installed on your machine. This makes it easier for you to have all of your shells included in the terminal without having to locate their executable files. These profiles are generated with the source property, which tells the terminal where to locate the proper executable.

Upon installing the terminal, it will set PowerShell as your default profile. To learn how to change your default profile, visit the Startup page.

Windows Terminal dynamic profiles
Configuration: Light Theme

Installing a new shell after installing Windows Terminal

Regardless of whether a new shell is installed before or after your terminal installation, the terminal will create a new profile for the newly installed shell.

Hide a profile

To hide a profile from your terminal dropdown menu, add the hidden property to the profile object in your settings.json file and set it to true.

Prevent a profile from being generated

To prevent a dynamic profile from being generated, you can add the profile generator to the disabledProfileSources array in your global settings. More information on this setting can be found on the Global settings page.

"disabledProfileSources": ["Windows.Terminal.Wsl", "Windows.Terminal.Azure", "Windows.Terminal.PowershellCore", "Windows.Terminal.SSH"]

Add a third party profile

If a 3rd party command line tool does not have a profile auto-generated into your settings.json file, you can add it manually. Below are profiles for a few common 3rd party tools for your reference.

Anaconda

Assuming that you’ve installed Anaconda into %USERPROFILE%Anaconda3:

{
    "commandline": "cmd.exe /k "%USERPROFILE%\Anaconda3\Scripts\activate.bat %USERPROFILE%\Anaconda3"",
    "icon": "%USERPROFILE%\Anaconda3\Menu\anaconda-navigator.ico",
    "name": "Anaconda3",
    "startingDirectory": "%USERPROFILE%"
}

cmder

Assuming that you’ve installed cmder into %CMDER_ROOT%:

{
    "commandline": "cmd.exe /k "%CMDER_ROOT%\vendor\init.bat"",
    "name": "cmder",
    "icon": "%CMDER_ROOT%\icons\cmder.ico",
    "startingDirectory": "%USERPROFILE%"
}

Cygwin

Assuming that you’ve installed Cygwin into C:Cygwin:

{
    "name": "Cygwin",
    "commandline": "C:\Cygwin\bin\bash --login -i",
    "icon": "C:\Cygwin\Cygwin.ico",
    "startingDirectory": "C:\Cygwin\bin"
}

![NOTE]
The starting directory of Cygwin is set in order for the path
to work. The default directory opened when starting Cygwin will be $HOME because
of the --login flag.

Far Manager

Assuming that you’ve installed Far into c:Program FilesFar Manager:

{
    "name": "Far",
    "commandline": ""c:\program files\far manager\far.exe"",
    "startingDirectory": "%USERPROFILE%",
    "useAcrylic": false
},

Git Bash

Assuming that you’ve installed Git Bash into C:\Program Files\Git:

{
    "name": "Git Bash",
    "commandline": "C:\Program Files\Git\bin\bash.exe -li",
    "icon": "C:\Program Files\Git\mingw64\share\git\git-for-windows.ico",
    "startingDirectory": "%USERPROFILE%"
}

Git Bash (WOW64)

Assuming that you’ve installed Git Bash into C:\Program Files (x86)\Git:

{
    "name": "Git Bash",
    "commandline": "%ProgramFiles(x86)%\Git\bin\bash.exe -li",
    "icon": "%ProgramFiles(x86)%\Git\mingw32\share\git\git-for-windows.ico",
    "startingDirectory": "%USERPROFILE%"
}

MSYS2

Assuming that you’ve installed MSYS2 into C:\msys64:

{
    "name": "MSYS2",
    "commandline": "C:\msys64\msys2_shell.cmd -defterm -no-start -mingw64",
    "icon": "C:\msys64\msys2.ico",
    "startingDirectory": "C:\msys64\home\user"
}

For more details, see the Terminals section of the MSYS2 documentation.

Overview

  1. Open settings with Ctrl+,
  2. You’ll want to append one of the profiles options below (depending on what version of git you have installed) to the "list": portion of the settings.json file:

Open settings.json in Windows Terminal sidebar

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{00000000-0000-0000-ba54-000000000001}",

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles
        },
        "list":
        [
            <put one of the configuration below right here>
        ]
    }
}

Profile options

Uncomment correct paths for commandline and icon if you are using:

  • Git for Windows in %PROGRAMFILES%
  • Git for Windows in %USERPROFILE%
  • If you’re using scoop
{
    "guid": "{00000000-0000-0000-ba54-000000000002}",
    "commandline": "%PROGRAMFILES%/Git/usr/bin/bash.exe -i -l",
    // "commandline": "%USERPROFILE%/AppData/Local/Programs/Git/bin/bash.exe -l -i",
    // "commandline": "%USERPROFILE%/scoop/apps/git/current/usr/bin/bash.exe -l -i",
    "icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
    // "icon": "%USERPROFILE%/AppData/Local/Programs/Git/mingw64/share/git/git-for-windows.ico",
    // "icon": "%USERPROFILE%/scoop/apps/git/current/usr/share/git/git-for-windows.ico",
    "name" : "Bash",
    "startingDirectory" : "%USERPROFILE%"
},

You can also add other options like:

{
    "guid": "{00000000-0000-0000-ba54-000000000002}",
    // ...
    "acrylicOpacity" : 0.75,
    "closeOnExit" : true,
    "colorScheme" : "Campbell",
    "cursorColor" : "#FFFFFF",
    "cursorShape" : "bar",
    "fontFace" : "Consolas",
    "fontSize" : 10,
    "historySize" : 9001,
    "padding" : "0, 0, 0, 0",
    "snapOnInput" : true,
    "useAcrylic" : true
}

Notes

  • make your own guid as of https://github.com/microsoft/terminal/pull/2475 this is no longer generated.
  • the guid can be used in in the globals > defaultProfile so you can press you can press CtrlShiftT
    or start a Windows terminal and it will start up bash by default
"defaultProfile" : "{00000000-0000-0000-ba54-000000000001}",
  • -l -i to make sure that .bash_profile gets loaded
  • use environment variables so they can map to different systems correctly.
  • target git/bin/bash.exe to avoid spawning off additional processes which saves about 10MB per process according to Process Explorer compared to using bin/bash or git-bash

I have my configuration that uses Scoop in https://gist.github.com/trajano/24f4edccd9a997fad8b4de29ea252cc8

sfy's user avatar

sfy

2,5221 gold badge18 silver badges21 bronze badges

answered Aug 6, 2019 at 5:09

Archimedes Trajano's user avatar

21

There are below things to do.

  1. Make sure the git command runs successfully in Command Prompt.

That means you need to add git to path when install git or add it to system environment later.

Run git in Command Prompt

  1. Update the file profile.json: open Settings by pressing Ctrl+, in Windows Terminal, click on Open JSON file in the sidebar, and add following snippet inside the word profiles:

Open settings.json in Windows Terminal sidebar

        { 
            "tabTitle": "Git Bash",
            "acrylicOpacity" : 0.75, 
            "closeOnExit" : true, 
            "colorScheme" : "Campbell", 
            "commandline" : "C:/Program Files/Git/bin/bash.exe --login", 
            "cursorColor" : "#FFFFFF", 
            "cursorShape" : "bar", 
            "fontFace" : "Consolas", 
            "fontSize" : 12, 
            "guid" : "{14ad203f-52cc-4110-90d6-d96e0f41b64d}", 
            "historySize" : 9001, 
            "icon": "ms-appdata:///roaming/git-bash_32px.ico",
            "name" : "Git Bash", 
            "padding" : "0, 0, 0, 0", 
            "snapOnInput" : true, 
            "useAcrylic" : true 
        }

The icon can be obtained here: git-bash_32px.ico

You can add icons for Tab to this location:

%LOCALAPPDATA%packagesMicrosoft.WindowsTerminal_8wekyb3d8bbweRoamingState

Put 32×32 PNG/icons in this folder, and then in profile.json you can reference the image resource with the path starting with ms-appdata://.

Note that, please make sure the Guidis correct and it matches the corresponding correct configurations.

  1. Test that git bash works in Windows Terminal.

The final result is below:
enter image description here

AryanTYB's user avatar

AryanTYB

4,1793 gold badges19 silver badges41 bronze badges

answered Aug 6, 2019 at 6:01

Bravo Yeung's user avatar

Bravo YeungBravo Yeung

7,9745 gold badges35 silver badges44 bronze badges

11

This is the complete answer (GitBash + color scheme + icon + context menu)

  1. Set default profile:
"globals": 
{
    "defaultProfile" : "{00000000-0000-0000-0000-000000000001}",
    ...
  1. Add GitBash profile
"profiles": [
    {
        "guid": "{00000000-0000-0000-0000-000000000001}",
        "acrylicOpacity": 0.75,
        "closeOnExit": true,
        "colorScheme": "GitBash",
        "commandline": ""%PROGRAMFILES%\Git\usr\bin\bash.exe" --login -i",
        "cursorColor": "#FFFFFF",
        "cursorShape": "bar",
        "fontFace": "Consolas",
        "fontSize": 10,
        "historySize": 9001,
        "icon": "%PROGRAMFILES%\Git\mingw64\share\git\git-for-windows.ico",
        "name": "GitBash",
        "padding": "0, 0, 0, 0",
        "snapOnInput": true,
        "startingDirectory": "%USERPROFILE%",
        "useAcrylic": false
    }
]
  1. Add GitBash color scheme
  "schemes": [
      {
          "background": "#000000",
          "black": "#0C0C0C",
          "blue": "#6060ff",
          "brightBlack": "#767676",
          "brightBlue": "#3B78FF",
          "brightCyan": "#61D6D6",
          "brightGreen": "#16C60C",
          "brightPurple": "#B4009E",
          "brightRed": "#E74856",
          "brightWhite": "#F2F2F2",
          "brightYellow": "#F9F1A5",
          "cyan": "#3A96DD",
          "foreground": "#bfbfbf",
          "green": "#00a400",
          "name": "GitBash",
          "purple": "#bf00bf",
          "red": "#bf0000",
          "white": "#ffffff",
          "yellow": "#bfbf00",
          "grey": "#bfbfbf"
      }
  ]
  1. To add a right-click context menu «Windows Terminal Here»
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOTDirectoryBackgroundshellwt]
@="Windows terminal here"
"Icon"="C:\Users\{YOUR_WINDOWS_USERNAME}\AppData\Local\Microsoft\WindowsApps\{YOUR_ICONS_FOLDER}\icon.ico"

[HKEY_CLASSES_ROOTDirectoryBackgroundshellwtcommand]
@=""C:\Users\{YOUR_WINDOWS_USERNAME}\AppData\Local\Microsoft\WindowsApps\wt.exe""
  • Replace {YOUR_WINDOWS_USERNAME} with your Windows username.
  • Create an icon folder, put the icon there and replace {YOUR_ICONS_FOLDER} with your icon folder.
  • Save this in a .reg file and run it.

answered Sep 20, 2019 at 11:46

Altin's user avatar

AltinAltin

2,1353 gold badges25 silver badges46 bronze badges

16

It’s Sept 2021, thankfully the latest Git Installation installer for Windows (mine was using 2.33.0.2) already has this option covered for us, for the sake of our laziness (and convenience, of course!)

Please install the Windows Terminal first before installing Git, although I haven’t try the otherway around, but better follow the sensible order. If the installation order is not the case, please let me know to update this answer.

You may find this handful checkbox at the bottom within the installation stage Select Components, just tick the box there and you’re good to go.
enter image description here

The settings.json file will be added the Git Bash profile automatically with correct Git Bash icon. My generated Git Bash profile is pretty standard and minimal.

{
    "guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
    "hidden": false,
    "name": "Git Bash",
    "source": "Git"
}

If Windows Terminal is running, close and launch again for the Git Bash option to be visible.

iron9's user avatar

iron9

3171 silver badge12 bronze badges

answered Sep 7, 2021 at 18:51

ThangLeQuoc's user avatar

ThangLeQuocThangLeQuoc

1,8941 gold badge16 silver badges28 bronze badges

1

Because most answers either show a lot of unrelated configuration or don’t show the configuration, I created my own answer that tries to be more focused. It is mainly based on the profile settings reference and Archimedes Trajano’s answer.

Steps

  1. Open PowerShell and enter [guid]::NewGuid() to generate a new GUID. We will use it at step 3.

    > [guid]::NewGuid()
    
    Guid
    ----
    a3da8d92-2f3f-4e36-9714-98876b6cb480
    
  2. Open the settings of Windows Terminal. (CTRL+,)

  3. Add the following JSON object to profiles.list. Replace guid with the one you generated at step 1.

    {
      "guid": "{a3da8d92-2f3f-4e36-9714-98876b6cb480}",
      "name": "Git Bash",
      "commandline": ""%PROGRAMFILES%\Git\usr\bin\bash.exe" -i -l",
      "icon": "%PROGRAMFILES%\Git\mingw64\share\git\git-for-windows.ico",
      "startingDirectory" : "%USERPROFILE%"
    },
    

Notes

  • There is currently an issue that you cannot use your arrow keys (and some other keys). It seems to work with the latest preview version, though. (issue #6859)

  • Specifying "startingDirectory" : "%USERPROFILE%" shouldn’t be necessary according to the reference. However, if I don’t specify it, the starting directory was different depending on how I started the terminal initially.

  • Settings that shall apply to all terminals can be specified in profiles.defaults.

  • I recommend to set "antialiasingMode": "cleartype" in profiles.defaults. You have to remove "useAcrylic" (if you have added it as suggested by some other answers) to make it work. It improves the quality of text rendering. However, you cannot have transparent background without useAcrylic. See issue #1298.

  • If you have problems with the cursor, you can try another shape like "cursorShape": "filledBox". See cursor settings for more information.

answered Jul 7, 2020 at 22:43

JojOatXGME's user avatar

JojOatXGMEJojOatXGME

2,8732 gold badges24 silver badges40 bronze badges

0

That’s how I’ve added mine in profiles json table,

{
    "guid": "{00000000-0000-0000-ba54-000000000002}",
    "name": "Git",
    "commandline": "C:/Program Files/Git/bin/bash.exe --login",
    "icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
    "startingDirectory": "%USERPROFILE%",
    "hidden": false
}

Martin Brisiak's user avatar

answered Jan 25, 2021 at 10:27

Ayoub EL ABOUSSI's user avatar

2

In case anyone is looking for a UI-Based solution. Here it is:

  1. Go to the Terminal’s settings.

  2. At the Right buttom side, look for the «Add new profile» option.
    Screenshot for the Terminal’s settings.

  3. Select «New Empty Profile»

  4. Now complete the fields with the information about your bash. If your installation locations are the default ones, you could use these:

  • Name: Git-Bash
  • Command line: C:Program FilesGitbinbash.exe
  • Startin directory: [Leave as default]
  • Icon: C:Program FilesGitmingw64sharegitgit-for-windows.ico
  • Tab title: Git-Bash
    Temrinal Settings completed
    You could also browse for the right files in case you need to.
  1. Hit Save button.

Final Result

Final Result. Bash terminal

answered Jan 13, 2022 at 15:23

Pedro Lebron's user avatar

1

Another item to note — in settings.json
I discovered if you don’t use
«commandline»: «C:/Program Files/Git/bin/bash.exe»

and instead use:
«commandline»: «C:/Program Files/Git/git-bash.exe»

the Git shell will open up in an independent window outside of Windows Terminal instead of on a tab — which is not the desired behavior.
In addition, the tab in Windows Terminal that opens will also need to be closed manually as it will display process exited information — [process exited with code 3221225786] etc.

Might save someone some headache

answered Jun 11, 2020 at 18:30

AB1's user avatar

AB1AB1

1611 silver badge6 bronze badges

4

Change the profiles parameter to "commandline": "%PROGRAMFILES%\Git\bin\bash.exe -l -i"

This works for me and allows for my .bash_profile alias autocomplete scripts to run.

answered Jul 3, 2019 at 9:55

Orbittman's user avatar

0

The new version of windows terminal can be configured through its GUI.

Setting -> Add new
Under "command line" add the path -> path/to/Git/bin/bash.exe

Mendy's user avatar

Mendy

7,2005 gold badges28 silver badges40 bronze badges

answered May 11, 2021 at 12:08

saveearth's user avatar

saveearthsaveearth

1711 silver badge4 bronze badges

1

If you want to display an icon and are using a dark theme. Which means the icon provided above doesn’t look that great. Then you can find the icon here

C:Program FilesGitmingw64sharegitgit-for-windows I copied it into.

%LOCALAPPDATA%packagesMicrosoft.WindowsTerminal_8wekyb3d8bbweRoamingState

and named it git-bash_32px as suggested above.

Control the opacity with CTRL + SHIFT + scrolling.

        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : ""%PROGRAMFILES%\git\usr\bin\bash.exe" -i -l",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{73225108-7633-47ae-80c1-5d00111ef646}",
            "historySize" : 9001,
            "icon" : "ms-appdata:///roaming/git-bash_32px.ico",
            "name" : "Bash",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : true
        },

answered Aug 12, 2019 at 11:57

Sigex's user avatar

SigexSigex

2,6022 gold badges22 silver badges25 bronze badges

As far as I know from my current windows terminal version 1.15.2874.0, you can get what you want with a simple manual click to configure it.
The prerequisites are

  1. your git bash client is installed.
  2. at least windows terminal version 1.15.2874.0 or higher.

Then complete the setup by following these steps.

  1. Open windows terminal and find «Settings» in the drop-down list in the top right corner of the menu bar (or use the shortcut ctrl+,);
  2. Click on «Add new profile» at the bottom of the left hand column, then the settings template screen will pop up automatically.
  3. interactive mouse click you want to set the «name», «executable path command line», «startup directory», «icon» value. For example, I set mine to "gitBash", "C:Program FilesGitbinbash.exe", "%USERPROFILE%", and «%USERPROFILE%» in order of customisation. "C:Program FilesGitmingw64sharegitgit-for-windows.ico".
  4. save.

The following screenshots are for reference.
enter image description here

enter image description here

answered Dec 4, 2022 at 5:50

xing cui's user avatar

Linux guy, here, sorry I am late; I am just installing git-bash for the first time and looking into what its command should be in Windows Terminal.

As far as I know

  • Cygwin is not Windows, but it provides a POSIX translation layer (cygwin*.dll) so that all those non-Windows executables can run. Even when a new computer program is compiled and built with cygwin, it still turns out a non-Windows executable and it still needs cygwin*.dll to run.
  • MSYS2 is mostly Windows with only a few tools that are probably difficult to port remaining non-Windows and requiring a POSIX translation layer to run (msys*.dll); but, most programs are actually Windows native executables. Even when a new computer program is compiled and built, it is my understanding that turns out a Windows native *.exe.

But I still don’t know how important it is that some of these MSYSTEM* and MINGW* environment variables be set or not, when I am going to be using MINGW compiler, anyway.

I did notice that, throughout this thread, both command lines keep showing up, namely, ./bin/bash and ./usr/bin/bash; so, I went ahead and launched them to compare their environments…they can turn out rather different.

Let it be known that, PREVIOUS to launching any of the shells below, I already have C:Gitmingw64bin and C:Gitusrbin as part of System variable PATH; I do this because I want to have the ability to use bash commands directly from CMD. But I don’t think this does anything to the results below.

                                        c:Gitbinbash.exe --login     c:Gitusrbinbash.exe --login
Environment Variable    c:Gitbinbash.exe                     c:Gitusrbinbash.exe
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EXEPATH                 c:gitbin      c:gitbin              n       n
HOSTNAME                n               MDXXXXXX                n       MDXXXXXX
MINGW_CHOST             n               x86_64-w64-mingw32      n       n
MINGW_PACKAGE_PREFIX    n               mingw-w64-x86_64        n       n
MINGW_PREFIX            n               /mingw64                n       n
MSYSTEM_CARCH           n               x86_64                  n       x86_64
MSYSTEM_CHOST           n               x86_64-w64-mingw32      n       x86_64-pc-msys
MSYSTEM_PREFIX          n               /mingw64                n       /usr
MSYSTEM                 MINGW64         MINGW64                 n       MSYS
PLINK_PROTOCOL          ssh             ssh                     n       n
SHELL                   n               /usr/bin/bash           n       /usr/bin/bash
TMPDIR                  n               /tmp                    n       /tmp

ORIGINAL_PATH           n               y                       n       y
ORIGINAL_TEMP           n               y                       n       y
ORIGINAL_TMP            n               y                       n       y
PATH                    /mingw64/bin:/usr/bin:$HOME/bin:$PATH
PATH                                    $HOME/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:$HOME/bin:$PATH
PATh                                                            $PATH
PATH                                                                    $HOME/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:$PATH

So, for good measure, it looks to me as if the more correct thing would be to use ./bin/bash --login; but I at this very moment, I am not sure what the difference will be, say, when it comes to actually compiling a brand new program with MINGW64/GCC; we shall see.

answered Oct 15, 2022 at 6:24

gsal's user avatar

gsalgsal

395 bronze badges

I did as follows:

  1. Add «%programfiles%GitBin» to your PATH
  2. On the profiles.json, set the desired command-line as «commandline» : «sh —cd-to-home»
  3. Restart the Windows Terminal

It worked for me.

answered Jul 4, 2019 at 11:54

LFrigoDeSouza's user avatar

Adding "%PROGRAMFILES%\Git\bin\bash.exe -l -i" doesn’t work for me. Because of space symbol (which is separator in cmd) in %PROGRAMFILES% terminal executes command "C:Program" instead of "C:Program FilesGitbinbash.exe -l -i". The solution should be something like adding quotation marks in json file, but I didn’t figure out how.
The only solution is to add «C:Program FilesGitbin» to %PATH% and write "commandline": "bash.exe" in profiles.json

answered Jul 17, 2019 at 7:32

Grigoriy's user avatar

4

To anyone who may suffer from missing bash history:
in already opened git bash, try initiate another bash — that supposed to load your profile if env vars are properly configured

If this is your case, you can automate it by adding following command line on startup:

C:progra~1gitusrbinbash.exe --login -l -i -c /c/progra~1/git/usr/bin/bash.exe

answered Jan 24, 2022 at 18:29

Lok Lokaj's user avatar

I just saw a tweet saying that Windows terminal is now generally available, so I had to give it a try.

After downloading from the store and booting up I realized that only powershell, cmd and wsl are listed by default (and also Azure which I don’t really care about).

Clicking around the UI a little there is a settings menu item that opens a JSON configuration file in notepad. This configuration file defines the behaviours of the terminal including the profiles that can be loaded.

After a bit of searching and documentation reading I came up with this profile which I now use for my git bash installation (I hope it can help you too).

{ "guid": "{00000000-0000-0000-ba88-000000000002}", "closeOnExit" : "always", "commandline" : ""%PROGRAMFILES%\git\usr\bin\bash.exe" -i -l", "icon" : "C:\Program Files\Git\mingw64\share\git\git-for-windows.ico", "name" : "Git Bash", "startingDirectory" : "%USERPROFILE%", "background": "#012456", "acrylicOpacity": 0.8, "useAcrylic": true }

Code language: JSON / JSON with Comments (json)

Some things to note:

  • guid – Randomly generated by me, just needs to be unique in the list of profiles as far as I can tell
  • closeOnExit, always – This needs to be always to actually close git bash panes when multiple panes are displayed side by side. If this is only set to true, on exit, your pane will remain with an exit code which would then need to be closed with another key combination.
  • background, acrylicOpacity, useAcrylic – These all alter the background appearance. I found these values to be the nice mix of readable, but not just boring black.

If you want to set this as your default profile you can also alter the default profile line near the top.

"defaultProfile": "{00000000-0000-0000-ba88-000000000002}",

Code language: JavaScript (javascript)

This should provide you with a new option to open a “Git bash” terminal tab, nicely displaying the git bash / mingw64 logo.

Observations

There is a bug open for automatically adding a git bash profile if git for windows is installed https://github.com/microsoft/terminal/issues/1394. This issue also includes some alternative defaults with more configured options but they don’t appear to be necessary.

Auto config reload seems to work fairly well for most things. if you change the logo path or some styling options the already opened terminal will automatically update.

%PROGRAMFILES% doesn’t appear to work for the icon value? (Hence why it is hardcoded above).

Why on earth are we being forced to edit json in notepad? I’m sure Microsoft could have come up with a pretty little JSON editor? Or at least some validation in the editor?

There are many other profile tweaks that can be done https://docs.microsoft.com/en-gb/windows/terminal/customize-settings/profile-settings

I really miss the “Quake style” that I could use win ConEmu. There is already a task for this too.

Terminal Icon

I admit I was not too impressed with the early beta versions of Windows Terminal, maybe because I use Cmder as my daily terminal driver and its features are excellent. However since Windows Terminal reached RTM at v1.0 it does seem a better quality product and with the demo at MS Build 2021 of the new features coming soon I can see that my number one feature request will be released soon – Quake Mode! Quake Mode enables the terminal to drop down from the top of screen on a keypress and as it is a feature of Cmder I use it every day to show/hide the terminal for those quick actions.

Windows Terminal does need some tweaking to get it to look and behave to my tastes, and unfortunately it still doesnt have a proper opacity setting (we have to make do with the smudgy ‘arcylic’ setting instead, but with some it is highly customisable via the settings.json file and settings UI. One thing that you can do is to add your own profiles, so I added my own profile for GitBash.

Assuming you have GitBash installed (via Git) then the below config should work but you’ll need to check your paths. Add this section to your profiles list in the settings.json file which can be found by opening Windows Terminal, choose ‘settings’ from the dropdown, then click the settings icon, the json file will then open. It is usually located somewhere like C:<YOURUSERNAME>RichAppDataLocalPackagesMicrosoft.WindowsTerminal_8wekyb3d8bbweLocalState.

{
 "closeOnExit": "always",
 "commandline": "C:\Program Files\Git\bin\bash.exe -I -l",
 "icon": "C:\Program Files\Git\mingw64\share\git\git-for-windows.ico",
 "name": "GitBash",
 "startingDirectory": "%USERPROFILE%",
 "tabTitle": "GitBash"
}

Its also useful to add a profile for the Developer Command Prompfor VS 2019, like this:

{
 "name": "Developer Command Prompt for VS 2019",
 "commandline": "%comspec%  /k "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"",
 "icon": "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\IDE\Assets\VisualStudio.70x70.contrast-standard_scale-180.png",
 "tabTitle": "Dev Cmd VS 2019"
}

This snippet assumes Visual Studio community edition is installed, if using Enterprise then correct the file paths to /Enterprise/ instead of /Community/. If you’re using Cmder and want to read how to add the Developer Command prompt to Cmder check out this post here.

To see the whole file check out my GitHub repo where I’ll keep my latest config file (whilst I remember to update) at https://github.com/RichHewlett/windows-terminal-config.


Понравилась статья? Поделить с друзьями:
  • Add an exclusion to windows security
  • Add an exception to the windows firewall
  • Add an exception for utorrent in windows firewall что это
  • Add an exception for utorrent in windows firewall что значит
  • Add an exception for torrent in windows firewall что это