-
Notifications
You must be signed in to change notification settings - Fork 612
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
installer: provide Windows Terminal Fragment Extension #339
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final location of git-bash-global.json and git-bash-local.json in installer repository TBD
I think they should go into git-extra
, but I'm not completely sure.
Mix and match of globally installed Terminal and locally installed Git (Bash) and vice versa does not work
I'm don't think we actually need to care how Windows terminal was installed.
Custom Git installation directories are not supported in the fragments
We might be able to disable the component for those unsupported cases with a check wether the value of {app}
is what we expect.
Should probably include a pre-generated UUIDv5 according to the Terminal docs for later modification
Unless I'm missreading the documentation, that's only for modifying profiles that Windows Terminal comes with.
The only profiles that can be modified through fragments are the default profiles, Command Prompt and PowerShell, as well as dynamic profiles.
and "dynamic profiles" refers to these:
Windows Terminal will automatically create Windows Subsystem for Linux (WSL) and PowerShell profiles for you if you have these shells installed on your machine.
So I think the way we're supposed to update our profile is by updating the json
file.
General side question: I presume the merge request should be a single commit in the end, i.e. all fixes for the issues squashed into a single commit with a proper description and signed-off-by line? |
We might also be able to avoid the install directory issues if we dynamically generate the procedure InstallWindowsTerminalFragment;
var
Res:Longint;
AppPath,XMLPath:String;
begin
if IsAdminInstallMode() then
JSONPath:=ExpandConstant('{commonappdata}\Microsoft\Windows Terminal\Fragments\Git\git-bash.json')
else
JSONPath:=ExpandConstant('{localappdata}\Microsoft\Windows Terminal\Fragments\Git\git-bash.json');
AppPath:=ExpandConstant('{app}');
SaveStringToFile(JSONPath,
'{'+
' "profiles": ['+
' {'+
' "name": "Git Bash",'+
' "commandline": "'+AppPath+'\usr\bin\bash.exe -i -l",'+
' "icon": "'+AppPath+'\{#MINGW_BITNESS}\share\git\git-for-windows.ico",'+
' "startingDirectory": "%USERPROFILE%"'+
' }'+
' ]'+
' }',False);
end; might work. |
Yes, exactly. just force push your updated commit and this PR will be updated accordingly. |
The good news: it works. The bad news: |
Right. This should work around that: procedure InstallWindowsTerminalFragment;
var
Res:Longint;
AppPath,XMLPath:String;
begin
if IsAdminInstallMode() then
JSONPath:=ExpandConstant('{commonappdata}\Microsoft\Windows Terminal\Fragments\Git\git-bash.json')
else
JSONPath:=ExpandConstant('{localappdata}\Microsoft\Windows Terminal\Fragments\Git\git-bash.json');
AppPath:=StringChangeEx(ExpandConstant('{app}'), '\', '/', True);
SaveStringToFile(JSONPath,
'{'+
' "profiles": ['+
' {'+
' "name": "Git Bash",'+
' "commandline": "'+AppPath+'/usr/bin/bash.exe -i -l",'+
' "icon": "'+AppPath+'/{#MINGW_BITNESS}/share/git/git-for-windows.ico",'+
' "startingDirectory": "%USERPROFILE%"'+
' }'+
' ]'+
' }',False);
end; |
So, I just pushed the changes you suggested:
I tested this with local admin user by installing Git with the local installer (from scratch). Verified installation by opening Terminal and starting the newly registered Git Bash. To finish I also verified the fragment was deleted from disk when Git was uninstalled. I could set up a local user (non-admin) in my VM as well if desired to test that part of the installation but not today anymore. |
That would be great. Thank you. |
Provides support for installing a basic Git Bash fragment for Windows Terminal (see git-for-windows/git/issues/3183 for details). Signed-off-by: Nikolas Grottendieck <git@nikolasgrottendieck.com>
I updated the procedure a little to log errors in case the file could not be saved. That aside the tests (clean installs for admin and non-admin) users as described before worked perfectly fine and the Fragment was successfully detected by Windows Terminal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most excellent!
The installer now offers to install [a Windows Terminal profile](#339). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
I think providing a pre-generated UUIDv5 would allow the user to modify/override/disable the profile shipped here in their own settings json. That was my reading of the docs anyway |
You're correct! Providing a stable guid of any sort will allow the user to customize git-for-windows once and have their customizations stick around even if you change the name of the profile. It will also make sure that you collide with yourself (which may or may not be good, depending on your view.) |
So in this case should it be in the "guid" property like in the normal settings, or is the uuid supposed to be called "updates" in the fragment extensions schema? |
This comment has been minimized.
This comment has been minimized.
So how would such a GUID be provided? Could you open a PR to do that? |
From microsoft/terminal#10374 (comment)
So we at least now know what the GUID should be. I at least am not sure what "property" it should be on, "guid" or "updates", for a fragment. |
I'll also make sure the docs clear this up 😄 When the fragment is creating a totally new profile, it should have a When the fragment is modifying an existing Terminal profile that came from another source (came with Terminal, detected via the Windows Subsystem for Linux detector, etc.) that was not the user¹, it should contain an ¹ This is so that a fragment cannot manipulate the user's personal profiles, no matter how hard it tries. |
In a diagram (which I'll formalize), it's like this:
|
Provides initial support for installing basic Git Bash fragments for Windows Terminal (see git-for-windows/git/issues/3183 for details).
Known Issues:
I am raising this WIP pull request to initiate the discussion on how to fix the aforementioned issues.