Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sschuberth opened this issue Jun 22, 2019 · 19 comments
Closed
Labels
Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Resolution-External For issues that are outside this codebase

Comments

@sschuberth
Copy link

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.

@sschuberth sschuberth added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jun 22, 2019
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 22, 2019
@ghost
Copy link

ghost commented Jun 22, 2019

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

@DHowett-MSFT
Copy link
Contributor

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.

@sschuberth
Copy link
Author

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.

@bgrainger
Copy link

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%"

@manisoft
Copy link

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

@DHowett-MSFT
Copy link
Contributor

see the same

Good thing somebody responded with the actual fix :)

@arseny92
Copy link

arseny92 commented 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

@sschuberth
Copy link
Author

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.

@iseeltf
Copy link

iseeltf commented 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

@DHowett-MSFT
Copy link
Contributor

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

@DHowett-MSFT DHowett-MSFT added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jun 24, 2019
@zadjii-msft
Copy link
Member

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

@zadjii-msft zadjii-msft reopened this Jul 2, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jul 2, 2019
@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. and removed Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. labels Jul 2, 2019
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Jul 2, 2019
@zadjii-msft zadjii-msft added Issue-Task It's a feature request, but it doesn't really need a major design. Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Jul 2, 2019
@mganthon
Copy link

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

@jeffrson
Copy link

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

@ghost
Copy link

ghost commented 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

@johnburnett
Copy link

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.)

@Okeanos
Copy link

Okeanos commented 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.

@dscho
Copy link
Member

dscho commented 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.

@zadjii-msft
Copy link
Member

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

/dup git-for-windows/git#3183
/dup git-for-windows/build-extra#339

@ghost
Copy link

ghost commented 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!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Resolution-External For issues that are outside this codebase
Projects
None yet
Development

No branches or pull requests