Keywords: Windows Terminal | Git Bash | Configuration | Environment Variables | GUID
Abstract: This comprehensive guide details the complete process of configuring Git Bash as the default shell in Windows Terminal. Covering everything from opening the settings file to configuring the profiles array, it includes commandline and icon settings for different Git installation paths, GUID generation, environment variable usage, and other key technical aspects. Through step-by-step instructions, it helps users resolve Git Bash integration issues while providing extensive customization options and best practice recommendations.
Configuration Overview
To successfully integrate Git Bash into Windows Terminal, proper configuration of the profiles settings in the settings.json file is required. First, open the terminal settings interface using the shortcut Ctrl+,, then navigate to the "list": array section for configuration editing.
Basic Configuration File Structure
The Windows Terminal configuration file follows a specific JSON schema, with core configurations located in the profiles list. Below shows the basic configuration file framework:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{00000000-0000-0000-ba54-000000000001}",
"profiles": {
"defaults": {
// Common settings applied to all profiles
},
"list": [
// Add Git Bash configuration here
]
}
}
Git Bash Configuration Options
Depending on the Git installation method, choose the appropriate commandline and icon path configurations:
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
"commandline": "%PROGRAMFILES%/Git/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%"
}
Advanced Customization Options
In addition to basic configuration, various visual and functional enhancement options can be added:
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
// ... Basic configuration
"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
}
Key Technical Points
GUID Generation: Each profile requires a unique GUID identifier, which can be created using online GUID generation tools. This GUID can be used to set the default startup configuration.
Command Line Parameters: The -l -i parameters ensure that the .bash_profile file is correctly loaded, which is crucial for environment variables and alias settings.
Environment Variable Usage: Using environment variables like %PROGRAMFILES% and %USERPROFILE% in configurations ensures compatibility across different systems.
Path Selection: It is recommended to use git/bin/bash.exe instead of git/usr/bin/bash.exe. The former correctly passes environment variables and ensures Git commands are available in PATH, although it spawns an additional process.
Configuration Verification and Testing
After completing the configuration, save the settings.json file and restart Windows Terminal. Select the newly added Bash configuration from the dropdown menu to verify that Git Bash starts normally and can execute Git commands. If issues occur, check if the paths are correct and if the GUID is unique.