Adding git bash to Windows terminal
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.
PATH was all messed up, lots of “command not found” errors. Forgot the -i (interactive) flag! Thanks for the example!
I think they figure you have VS Code if you’re using the terminal, which is where it opens by default for me. Preciate this example. I’ve recently found myself having to develop some Windows specific things not supported in Linux so every non powershell option is a giant leap for mankind.
[…] Adding git bash to Windows terminal (new in 2020) […]
I’m pretty sure it opens with the default JSON editor. Didn’t realize my default editor was Visual Studio (read: not code) until I tired to edit it! Apologies for the thread bump 🙂
You can create a Git Bash profile automatically in Windows Terminal during Git setup.
https://twitter.com/cinnamon_msft/status/1427740549008687104
[…] Adding git bash to Windows Terminal (was #3) […]