Upon installation, add a Git Bash profile, if Git for Windows is present #1862

Closed
opened 2026-01-30 22:40:21 +00:00 by claunia · 19 comments
Owner

Originally created by @sschuberth on GitHub (Jun 22, 2019).

Summary of the new feature/enhancement

When installing the terminal for the first time, it would be nice if a profile for Bash from Git for Windows would be automatically provided if Git for Windows is installed.

Proposed technical implementation details (optional)

Auto-detect via installer registry keys whether Git for Windows in installed, and if so, add an entry to profiles.json to run Bash from Git for Windows in the terminal app.

Originally created by @sschuberth on GitHub (Jun 22, 2019). # Summary of the new feature/enhancement When installing the terminal for the first time, it would be nice if a profile for Bash from Git for Windows would be automatically provided if Git for Windows is installed. # Proposed technical implementation details (optional) Auto-detect via installer registry keys whether Git for Windows in installed, and if so, add an entry to `profiles.json` to run Bash from Git for Windows in the terminal app.
Author
Owner

@ghost commented on GitHub (Jun 22, 2019):

Tried to manually add but it opens in a separate window. Not sure if is compatible

@ghost commented on GitHub (Jun 22, 2019): Tried to manually add but it opens in a separate window. Not sure if is compatible
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 22, 2019):

If you are launching “mintty,” or if git bash is using “mintty,” it will launch in a separate window. We can’t fix that: they’ve chosen to launch their own terminal emulator.

@DHowett-MSFT commented on GitHub (Jun 22, 2019): If you are launching “mintty,” or if git bash is using “mintty,” it will launch in a separate window. We can’t fix that: they’ve chosen to launch their own terminal emulator.
Author
Owner

@sschuberth commented on GitHub (Jun 22, 2019):

The "trick" is that you must no run git-bash.exe (or git-cmd.exe) from the Git for Windows installation directory, as these hard-code to use mintty (or conhost) as the terminal, but you should use bin\bash.exe which just is the plain shell interpreter.

@sschuberth commented on GitHub (Jun 22, 2019): The "trick" is that you must no run `git-bash.exe` (or `git-cmd.exe`) from the Git for Windows installation directory, as these hard-code to use *mintty* (or *conhost*) as the terminal, but you should use `bin\bash.exe` which just is the plain shell interpreter.
Author
Owner

@bgrainger commented on GitHub (Jun 22, 2019):

Specifically, use this JSON fragment to open Git Bash (if it's installed in the default location):

    "commandline" : "C:\\Program Files\\Git\\bin\\bash.exe",
    "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
    "name" : "Git Bash",
    "startingDirectory" : "%HOMEDRIVE%%HOMEPATH%"
@bgrainger commented on GitHub (Jun 22, 2019): Specifically, use this JSON fragment to open Git Bash (if it's installed in the default location): ```json "commandline" : "C:\\Program Files\\Git\\bin\\bash.exe", "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico", "name" : "Git Bash", "startingDirectory" : "%HOMEDRIVE%%HOMEPATH%" ```
Author
Owner

@manisoft commented on GitHub (Jun 22, 2019):

Tried to manually add but it opens in a separate window. Not sure if is compatible

I also tried and see the same... it opens the git-bash.exe as a separate window

@manisoft commented on GitHub (Jun 22, 2019): > Tried to manually add but it opens in a separate window. Not sure if is compatible I also tried and see the same... it opens the git-bash.exe as a separate window
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 22, 2019):

see the same

Good thing somebody responded with the actual fix :)

@DHowett-MSFT commented on GitHub (Jun 22, 2019): > see the same Good thing somebody responded with the actual fix :)
Author
Owner

@arseny92 commented on GitHub (Jun 22, 2019):

Issue extension and suggested name: Scan installed shell interpreters on Terminal first run/install and initial profiles.json generation

Scanning PATH for known shells at their default install locations. If a shell is present, add it (along with any custom fixes such as the bin\bash.exe for Git for Windows. Essentially an enhancement for the function that scans names of configured WSL distros.
Fix PowerShell Core: on initial profiles.json generation, scan installed versions and name accordingly (PowerShell Core <version>). Can get version from exe properties. Add icons to ms-appx://ProfileIcons (pscore has some in it's assets folder. If detecting third-party interpreters, can opt to try get from exe or ico if present in shell path). So that if you have both PSCore6 and PSCore7.0.0-preview or any other version installed prior to running Terminal for the first time, all PowerShells get registered on profiles.json.
Also to fix initial detection of cmd

Ideally (for this manually edited my profiles.json, but the intent is to have shells automatically detected) :

screenshot 2019-06-22 003

@arseny92 commented on GitHub (Jun 22, 2019): Issue extension and suggested name: Scan installed shell interpreters on Terminal first run/install and initial profiles.json generation Scanning PATH for known shells at their default install locations. If a shell is present, add it (along with any custom fixes such as the `bin\bash.exe` for Git for Windows. Essentially an enhancement for the function that scans names of configured WSL distros. Fix PowerShell Core: on initial profiles.json generation, scan installed versions and name accordingly (`PowerShell Core <version>`). Can get version from exe properties. Add icons to `ms-appx://ProfileIcons` (pscore has some in it's assets folder. If detecting third-party interpreters, can opt to try get from exe or ico if present in shell path). So that if you have both PSCore6 and PSCore7.0.0-preview or any other version installed prior to running Terminal for the first time, all PowerShells get registered on profiles.json. Also to fix initial detection of cmd Ideally (for this manually edited my profiles.json, but the intent is to have shells automatically detected) : ![screenshot 2019-06-22 003](https://user-images.githubusercontent.com/13212955/59968905-a4696580-954a-11e9-9db9-63fb77928312.png)
Author
Owner

@sschuberth commented on GitHub (Jun 24, 2019):

Scanning PATH for known shells at their default install locations.

Note that, strictly speaking, scanning PATH is not enough, as esp. Git for Windows often is not in the system PATH. Instead, Git for Windows (or shells in general) should be discovered by looking at the registry like I had proposed above. At the concrete example of Git for Windows the registry key to look at is InstallLocation at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Git_is1.

@sschuberth commented on GitHub (Jun 24, 2019): > Scanning PATH for known shells at their default install locations. Note that, strictly speaking, scanning PATH is not enough, as esp. Git for Windows often is not in the system PATH. Instead, Git for Windows (or shells in general) should be discovered by looking at the registry like I had proposed above. At the concrete example of Git for Windows the registry key to look at is `InstallLocation` at `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Git_is1`.
Author
Owner

@iseeltf commented on GitHub (Jun 24, 2019):

Tried to manually add but it opens in a separate window. Not sure if is compatible

I also tried and see the same... it opens the git-bash.exe as a separate window

use bin\bash.exe instead of git-bash.exe

@iseeltf commented on GitHub (Jun 24, 2019): > > Tried to manually add but it opens in a separate window. Not sure if is compatible > > I also tried and see the same... it opens the git-bash.exe as a separate window use bin\bash.exe instead of git-bash.exe
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 24, 2019):

We've got dynamic profile generation on our radar; #754 is in spec review #1258

@DHowett-MSFT commented on GitHub (Jun 24, 2019): We've got dynamic profile generation on our radar; #754 is in spec review #1258
Author
Owner

@zadjii-msft commented on GitHub (Jul 2, 2019):

I'm actually going to re-open this to make sure that it gets done once #754 is complete.

@zadjii-msft commented on GitHub (Jul 2, 2019): I'm actually going to re-open this to make sure that it gets done once #754 is complete.
Author
Owner

@mganthon commented on GitHub (Aug 12, 2019):

Here is a code snippet of my config file that has it loading in the terminal. Thanks to everyone who contributed to the solution. I'm using a custom icon, so it won't be in your path.

      {
        "acrylicOpacity": 0.5,
        "background": "#012456",
        "closeOnExit": true,
        "colorScheme": "Solarized Dark",
        "commandline": "C:\\Program Files\\Git\\bin\\bash.exe",
        "cursorColor": "#FFFFFF",
        "cursorShape": "bar",
        "fontFace": "Consolas",
        "fontSize": 10,
        "guid": "{72a69aca-322e-465d-a799-1d64dff65269}",
        "historySize": 9001,
        "icon": "C:\\Program Files\\Git\\git-bash.png",
        "name": "Git Bash",
        "padding": "0, 0, 0, 0",
        "snapOnInput": true,
        "startingDirectory": "%USERPROFILE%",
        "useAcrylic": false
      }

image

@mganthon commented on GitHub (Aug 12, 2019): Here is a code snippet of my config file that has it loading in the terminal. Thanks to everyone who contributed to the solution. I'm using a custom icon, so it won't be in your path. ``` { "acrylicOpacity": 0.5, "background": "#012456", "closeOnExit": true, "colorScheme": "Solarized Dark", "commandline": "C:\\Program Files\\Git\\bin\\bash.exe", "cursorColor": "#FFFFFF", "cursorShape": "bar", "fontFace": "Consolas", "fontSize": 10, "guid": "{72a69aca-322e-465d-a799-1d64dff65269}", "historySize": 9001, "icon": "C:\\Program Files\\Git\\git-bash.png", "name": "Git Bash", "padding": "0, 0, 0, 0", "snapOnInput": true, "startingDirectory": "%USERPROFILE%", "useAcrylic": false } ``` ![image](https://user-images.githubusercontent.com/3390669/62882805-a6f16b80-bd00-11e9-950b-7652065191a7.png)
Author
Owner

@jeffrson commented on GitHub (Oct 16, 2019):

Just to add some notes I found (about the actual bash.exe path to use and startup parameters to launch a login shell):
https://stackoverflow.com/a/57369284/564226

@jeffrson commented on GitHub (Oct 16, 2019): Just to add some notes I found (about the actual bash.exe path to use and startup parameters to launch a login shell): https://stackoverflow.com/a/57369284/564226
Author
Owner

@ghost commented on GitHub (Sep 14, 2020):

You can find the Git for Windows icon at the following path:

C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico

image

@ghost commented on GitHub (Sep 14, 2020): You can find the Git for Windows icon at the following path: ``` C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico ``` ![image](https://user-images.githubusercontent.com/55477181/93039314-85dd1600-f68a-11ea-82d1-0e1d90b6f0ad.png)
Author
Owner

@johnburnett commented on GitHub (Dec 8, 2020):

Just to add some notes I found (about the actual bash.exe path to use and startup parameters to launch a login shell):
https://stackoverflow.com/a/57369284/564226

For posterity - this should be using "%PROGRAMFILES%\Git\bin\bash.exe", not "%PROGRAMFILES%\Git\usr\bin\bash.exe". The latter doesn't seem to fully initialize the environment for bash (e.g. https://stackoverflow.com/questions/56839307/adding-git-bash-to-the-new-windows-terminal#comment110596050_57369284 ... also, compare the results of "uname -s" between a stock git bash outside of Terminal and what you get in Terminal when referencing the above two executables. In my case, only "Git\bin\bash.exe" gives the "correct" result of MINGW64_T. The latter gives MSYS_NT.)

@johnburnett commented on GitHub (Dec 8, 2020): > Just to add some notes I found (about the actual bash.exe path to use and startup parameters to launch a login shell): > https://stackoverflow.com/a/57369284/564226 For posterity - this should be using "%PROGRAMFILES%\Git\bin\bash.exe", not "%PROGRAMFILES%\Git\usr\bin\bash.exe". The latter doesn't seem to fully initialize the environment for bash (e.g. https://stackoverflow.com/questions/56839307/adding-git-bash-to-the-new-windows-terminal#comment110596050_57369284 ... also, compare the results of "uname -s" between a stock git bash outside of Terminal and what you get in Terminal when referencing the above two executables. In my case, only "Git\bin\bash.exe" gives the "correct" result of MINGW64_T. The latter gives MSYS_NT.)
Author
Owner

@Okeanos commented on GitHub (May 9, 2021):

Btw. there's a reverse of this issue open at Git for Windows#3183 with a matching Pull Request already open and being worked on.
Once merged and released Git for Windows will offer to install a very basic fragment extension as additional installation option.

@Okeanos commented on GitHub (May 9, 2021): Btw. there's a reverse of this issue open at [Git for Windows#3183](https://github.com/git-for-windows/git/issues/3183) with a matching Pull Request already open and being worked on. Once merged and released Git for Windows will offer to install a very basic fragment extension as additional installation option.
Author
Owner

@dscho commented on GitHub (May 18, 2021):

The Git for Windows PR was merged, and Git for Windows v2.32.0-rc1 (or the next snapshot) will have this option.

@dscho commented on GitHub (May 18, 2021): The Git for Windows PR was merged, and Git for Windows v2.32.0-rc1 (or the next [snapshot](https://wingit.blob.core.windows.net/files/index.html)) will have this option.
Author
Owner

@zadjii-msft commented on GitHub (May 18, 2021):

That's awesome to hear! I guess I can close this then!

/dup https://github.com/git-for-windows/git/issues/3183
/dup https://github.com/git-for-windows/build-extra/pull/339

@zadjii-msft commented on GitHub (May 18, 2021): That's awesome to hear! I guess I can close this then! /dup https://github.com/git-for-windows/git/issues/3183 /dup https://github.com/git-for-windows/build-extra/pull/339
Author
Owner

@ghost commented on GitHub (May 18, 2021):

Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!

@ghost commented on GitHub (May 18, 2021): Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1862