将 Git-Bash 添加到新的 Windows 终端
Adding Git-Bash to the new Windows Terminal
我正在尝试将新终端 (Git Bash) 添加到新的 Windows 终端。但是,我无法让它工作。
我尝试将 profiles
数组中的 commandline
属性 更改为 git-bash.exe
但没有成功。
有没有人知道如何让它工作?
将配置文件参数更改为 "commandline": "%PROGRAMFILES%\Git\bin\bash.exe -l -i"
这对我有用,并允许我的 .bash_profile 别名自动完成脚本到 运行。
我做了如下操作:
- 将“%programfiles%\Git\Bin”添加到您的 PATH
- 在 profiles.json 上,将所需的 command-line 设置为 "commandline" :"sh --cd-to-home"
- 重新启动 Windows 终端
对我有用。
添加 "%PROGRAMFILES%\Git\bin\bash.exe -l -i"
对我不起作用。由于 %PROGRAMFILES% 中的 space 符号(cmd 中的分隔符),终端执行命令 "C:\Program"
而不是 "C:\Program Files\Git\bin\bash.exe -l -i"
。解决方案应该是在 json 文件中添加引号,但我没有弄清楚如何。
唯一的解决办法是在%PATH%中加入"C:\Program Files\Git\bin",在profiles.json
中写入"commandline": "bash.exe"
概览
- 使用 Ctrl+、
打开设置
- 您需要将以下配置文件选项之一(取决于您安装的 git 版本)附加到
settings.json
文件的 "list":
部分:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{00000000-0000-0000-ba54-000000000001}",
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles
},
"list":
[
<put one of the configuration below right here>
]
}
}
配置文件选项
取消注释 commandline
和 icon
的正确路径,如果您正在使用:
- Git 对于
%PROGRAMFILES%
中的 Windows
- Git 对于
%USERPROFILE%
中的 Windows
- 如果您正在使用 scoop
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
"commandline": "%PROGRAMFILES%/Git/usr/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%"
},
您还可以添加其他选项,例如:
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
// ...
"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
}
备注
- 制作你自己的
guid
自 https://github.com/microsoft/terminal/pull/2475 起不再生成。
guid
可以用在 globals
> defaultProfile
所以你可以按 你可以按 CtrlShiftT
或者启动一个 Windows 终端,它将默认启动 bash
"defaultProfile" : "{00000000-0000-0000-ba54-000000000001}",
-l -i
以确保 .bash_profile
被加载
- 使用环境变量,以便它们可以正确映射到不同的系统。
- target
git/bin/bash.exe
以避免产生额外的进程,根据 Process Explorer 与使用 bin/bash 或 git-bash[=66 相比,每个进程节省大约 10MB =]
我的配置在 https://gist.github.com/trajano/24f4edccd9a997fad8b4de29ea252cc8
中使用 Scoop
有以下事情要做。
- 确保
git
命令在命令提示符中成功运行。
也就是说安装时需要在路径中添加git
git 或者稍后添加到系统环境中
- 更新文件
profile.json
:在[=61=中按Ctrl+、打开Settings
] 终端,单击边栏中的打开 JSON 文件,然后在 profiles
: 一词中添加以下代码片段
{
"tabTitle": "Git Bash",
"acrylicOpacity" : 0.75,
"closeOnExit" : true,
"colorScheme" : "Campbell",
"commandline" : "C:/Program Files/Git/bin/bash.exe --login",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 12,
"guid" : "{14ad203f-52cc-4110-90d6-d96e0f41b64d}",
"historySize" : 9001,
"icon": "ms-appdata:///roaming/git-bash_32px.ico",
"name" : "Git Bash",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"useAcrylic" : true
}
图标可以在这里获取:git-bash_32px.ico
您可以将 Tab 的图标添加到此位置:
%LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState
把32x32PNG/icons放在这个文件夹里,然后在profile.json
里就可以引用ms-appdata://
.
开头路径的图片资源了
请注意,请确保Guid
是正确的并且匹配相应的正确配置。
- 测试 git bash 在 Windows 终端中工作。
最终结果如下:
如果你想显示一个图标并且正在使用深色主题。这意味着上面提供的图标看起来不太好。然后你可以在这里找到图标
C:\Program Files\Git\mingw64\share\git\git-for-windows
我复制进去了
%LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState
并按照上面的建议将其命名为 git-bash_32px
。
使用 CTRL + SHIFT + 滚动控制不透明度。
{
"acrylicOpacity" : 0.75,
"closeOnExit" : true,
"colorScheme" : "Campbell",
"commandline" : "\"%PROGRAMFILES%\git\usr\bin\bash.exe\" -i -l",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 10,
"guid" : "{73225108-7633-47ae-80c1-5d00111ef646}",
"historySize" : 9001,
"icon" : "ms-appdata:///roaming/git-bash_32px.ico",
"name" : "Bash",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "%USERPROFILE%",
"useAcrylic" : true
},
这是完整的答案(GitBash + 配色方案 + 图标 + 上下文菜单)
- 设置默认配置文件:
"globals":
{
"defaultProfile" : "{00000000-0000-0000-0000-000000000001}",
...
- 添加 GitBash 配置文件
"profiles": [
{
"guid": "{00000000-0000-0000-0000-000000000001}",
"acrylicOpacity": 0.75,
"closeOnExit": true,
"colorScheme": "GitBash",
"commandline": "\"%PROGRAMFILES%\Git\usr\bin\bash.exe\" --login -i -l",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"fontFace": "Consolas",
"fontSize": 10,
"historySize": 9001,
"icon": "%PROGRAMFILES%\Git\mingw64\share\git\git-for-windows.ico",
"name": "GitBash",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%USERPROFILE%",
"useAcrylic": false
}
]
- 添加 GitBash 配色方案
"schemes": [
{
"background": "#000000",
"black": "#0C0C0C",
"blue": "#6060ff",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cyan": "#3A96DD",
"foreground": "#bfbfbf",
"green": "#00a400",
"name": "GitBash",
"purple": "#bf00bf",
"red": "#bf0000",
"white": "#ffffff",
"yellow": "#bfbf00",
"grey": "#bfbfbf"
}
]
- 添加右键单击上下文菜单“Windows Terminal Here”
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="C:\Users\{YOUR_WINDOWS_USERNAME}\AppData\Local\Microsoft\WindowsApps\{YOUR_ICONS_FOLDER}\icon.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="\"C:\Users\{YOUR_WINDOWS_USERNAME}\AppData\Local\Microsoft\WindowsApps\wt.exe\""
- 将
{YOUR_WINDOWS_USERNAME}
替换为您的 Windows 用户名。
- 创建一个图标文件夹,将图标放在那里并将
{YOUR_ICONS_FOLDER}
替换为您的图标文件夹。
- 将其保存在
.reg
文件中并 运行 它。
另一个需要注意的事项 - 在 settings.json
我发现如果你不使用
"commandline": "C:/Program Files/Git/bin/bash.exe"
而是使用:
"commandline": "C:/Program Files/Git/git-bash.exe"
Git shell 将在 Windows 终端之外的独立 window 中打开,而不是在选项卡上打开 - 这不是所需的行为。
此外,Windows 打开的终端中的选项卡也需要手动关闭,因为它会显示进程退出信息 - [进程退出代码 3221225786] 等
可能会让人头疼
因为大多数答案要么显示大量不相关的配置,要么不显示配置,我创建了自己的答案,试图更加集中。它主要基于profile settings reference and .
步骤
打开PowerShell并输入[guid]::NewGuid()
生成新的GUID。我们将在第 3 步使用它。
> [guid]::NewGuid()
Guid
----
a3da8d92-2f3f-4e36-9714-98876b6cb480
打开Windows终端的设置。 (CTRL+,)
将以下 JSON 对象添加到 profiles.list
。将 guid
替换为您在步骤 1 中生成的
{
"guid": "{a3da8d92-2f3f-4e36-9714-98876b6cb480}",
"name": "Git Bash",
"commandline": "\"%PROGRAMFILES%\Git\usr\bin\bash.exe\" -i -l",
"icon": "%PROGRAMFILES%\Git\mingw64\share\git\git-for-windows.ico",
"startingDirectory" : "%USERPROFILE%"
},
备注
目前存在一个问题,您无法使用箭头键(和其他一些键)。不过,它似乎适用于最新的预览版。 (issue #6859)
不必指定 "startingDirectory" : "%USERPROFILE%"
according to the reference。但是,如果我不指定它,起始目录会因我最初启动终端的方式而有所不同。
可以在profiles.defaults
中指定适用于所有终端的设置。
我建议在profiles.defaults
中设置"antialiasingMode": "cleartype"
。您必须删除 "useAcrylic"
(如果您按照其他一些答案的建议添加了它)才能使其正常工作。它提高了文本呈现的质量。但是,没有 useAcrylic
就不能有透明背景。参见 issue #1298。
如果您对光标有问题,可以尝试其他形状,例如 "cursorShape": "filledBox"
。有关详细信息,请参阅 cursor settings。
这就是我在配置文件中添加我的方式 json table,
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
"name": "Git",
"commandline": "C:/Program Files/Git/bin/bash.exe --login",
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
"startingDirectory": "%USERPROFILE%",
"hidden": false
}
新版本的 windows 终端可以通过其 GUI 进行配置。
Setting -> Add new
Under "command line" add the path -> path/to/Git/bin/bash.exe
现在是 2021 年 9 月,谢天谢地,最新的 Git Installation installer for Windows(我使用的是 2.33.0.2)已经为我们提供了这个选项,为了我们的懒惰(当然还有方便!)
请在安装Git之前先安装Windows终端,虽然我没有尝试相反的方式,但最好遵循合理的顺序。如果安装顺序不是这样,请让我知道更新此答案。
您可能会在安装阶段 Select 组件 的底部找到这个少数复选框,只需勾选那里的复选框即可。
settings.json
文件将自动添加 Git Bash 配置文件,并带有正确的 Git Bash 图标。我生成的 Git Bash 配置文件非常标准且最小。
{
"guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
"hidden": false,
"name": "Git Bash",
"source": "Git"
}
如果 Windows 终端是 运行,请关闭并再次启动以使 Git Bash 选项可见。
万一有人正在寻找 UI-Based 解决方案。这是:
转到终端的设置。
在右下角,找到“添加新配置文件”选项。
Screenshot for the Terminal's settings.
Select“新建空配置文件”
现在用您的 bash 信息填写字段。如果您的安装位置是默认位置,您可以使用这些:
- 姓名: Git-Bash
- 命令行: C:\Program Files\Git\bin\bash.exe
- 起始目录:[保留默认值]
- 图标:C:\程序Files\Git\mingw64\share\git\git-for-windows.ico
- 选项卡标题:Git-Bash
Temrinal Settings completed
如果需要,您还可以浏览合适的文件。
- 点击保存按钮。
最终结果
致任何可能因缺失 bash 历史而受苦的人:
在已经打开的 git bash 中,尝试启动另一个 bash - 如果环境变量配置正确,它应该加载您的配置文件
如果是这种情况,您可以通过在启动时添加以下命令行使其自动化:
C:\progra~1\git\usr\bin\bash.exe --login -l -i -c /c/progra~1/git/usr/bin/bash.exe
我正在尝试将新终端 (Git Bash) 添加到新的 Windows 终端。但是,我无法让它工作。
我尝试将 profiles
数组中的 commandline
属性 更改为 git-bash.exe
但没有成功。
有没有人知道如何让它工作?
将配置文件参数更改为 "commandline": "%PROGRAMFILES%\Git\bin\bash.exe -l -i"
这对我有用,并允许我的 .bash_profile 别名自动完成脚本到 运行。
我做了如下操作:
- 将“%programfiles%\Git\Bin”添加到您的 PATH
- 在 profiles.json 上,将所需的 command-line 设置为 "commandline" :"sh --cd-to-home"
- 重新启动 Windows 终端
对我有用。
添加 "%PROGRAMFILES%\Git\bin\bash.exe -l -i"
对我不起作用。由于 %PROGRAMFILES% 中的 space 符号(cmd 中的分隔符),终端执行命令 "C:\Program"
而不是 "C:\Program Files\Git\bin\bash.exe -l -i"
。解决方案应该是在 json 文件中添加引号,但我没有弄清楚如何。
唯一的解决办法是在%PATH%中加入"C:\Program Files\Git\bin",在profiles.json
"commandline": "bash.exe"
概览
- 使用 Ctrl+、 打开设置
- 您需要将以下配置文件选项之一(取决于您安装的 git 版本)附加到
settings.json
文件的"list":
部分:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{00000000-0000-0000-ba54-000000000001}",
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles
},
"list":
[
<put one of the configuration below right here>
]
}
}
配置文件选项
取消注释 commandline
和 icon
的正确路径,如果您正在使用:
- Git 对于
%PROGRAMFILES%
中的 Windows
- Git 对于
%USERPROFILE%
中的 Windows
- 如果您正在使用 scoop
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
"commandline": "%PROGRAMFILES%/Git/usr/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%"
},
您还可以添加其他选项,例如:
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
// ...
"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
}
备注
- 制作你自己的
guid
自 https://github.com/microsoft/terminal/pull/2475 起不再生成。 guid
可以用在globals
>defaultProfile
所以你可以按 你可以按 CtrlShiftT 或者启动一个 Windows 终端,它将默认启动 bash
"defaultProfile" : "{00000000-0000-0000-ba54-000000000001}",
-l -i
以确保.bash_profile
被加载- 使用环境变量,以便它们可以正确映射到不同的系统。
- target
git/bin/bash.exe
以避免产生额外的进程,根据 Process Explorer 与使用 bin/bash 或 git-bash[=66 相比,每个进程节省大约 10MB =]
我的配置在 https://gist.github.com/trajano/24f4edccd9a997fad8b4de29ea252cc8
中使用 Scoop有以下事情要做。
- 确保
git
命令在命令提示符中成功运行。
也就是说安装时需要在路径中添加git
git 或者稍后添加到系统环境中
- 更新文件
profile.json
:在[=61=中按Ctrl+、打开Settings
] 终端,单击边栏中的打开 JSON 文件,然后在profiles
: 一词中添加以下代码片段
{
"tabTitle": "Git Bash",
"acrylicOpacity" : 0.75,
"closeOnExit" : true,
"colorScheme" : "Campbell",
"commandline" : "C:/Program Files/Git/bin/bash.exe --login",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 12,
"guid" : "{14ad203f-52cc-4110-90d6-d96e0f41b64d}",
"historySize" : 9001,
"icon": "ms-appdata:///roaming/git-bash_32px.ico",
"name" : "Git Bash",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"useAcrylic" : true
}
图标可以在这里获取:git-bash_32px.ico
您可以将 Tab 的图标添加到此位置:
%LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState
把32x32PNG/icons放在这个文件夹里,然后在profile.json
里就可以引用ms-appdata://
.
请注意,请确保Guid
是正确的并且匹配相应的正确配置。
- 测试 git bash 在 Windows 终端中工作。
最终结果如下:
如果你想显示一个图标并且正在使用深色主题。这意味着上面提供的图标看起来不太好。然后你可以在这里找到图标
C:\Program Files\Git\mingw64\share\git\git-for-windows
我复制进去了
%LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState
并按照上面的建议将其命名为 git-bash_32px
。
使用 CTRL + SHIFT + 滚动控制不透明度。
{
"acrylicOpacity" : 0.75,
"closeOnExit" : true,
"colorScheme" : "Campbell",
"commandline" : "\"%PROGRAMFILES%\git\usr\bin\bash.exe\" -i -l",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 10,
"guid" : "{73225108-7633-47ae-80c1-5d00111ef646}",
"historySize" : 9001,
"icon" : "ms-appdata:///roaming/git-bash_32px.ico",
"name" : "Bash",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "%USERPROFILE%",
"useAcrylic" : true
},
这是完整的答案(GitBash + 配色方案 + 图标 + 上下文菜单)
- 设置默认配置文件:
"globals":
{
"defaultProfile" : "{00000000-0000-0000-0000-000000000001}",
...
- 添加 GitBash 配置文件
"profiles": [
{
"guid": "{00000000-0000-0000-0000-000000000001}",
"acrylicOpacity": 0.75,
"closeOnExit": true,
"colorScheme": "GitBash",
"commandline": "\"%PROGRAMFILES%\Git\usr\bin\bash.exe\" --login -i -l",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"fontFace": "Consolas",
"fontSize": 10,
"historySize": 9001,
"icon": "%PROGRAMFILES%\Git\mingw64\share\git\git-for-windows.ico",
"name": "GitBash",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%USERPROFILE%",
"useAcrylic": false
}
]
- 添加 GitBash 配色方案
"schemes": [
{
"background": "#000000",
"black": "#0C0C0C",
"blue": "#6060ff",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cyan": "#3A96DD",
"foreground": "#bfbfbf",
"green": "#00a400",
"name": "GitBash",
"purple": "#bf00bf",
"red": "#bf0000",
"white": "#ffffff",
"yellow": "#bfbf00",
"grey": "#bfbfbf"
}
]
- 添加右键单击上下文菜单“Windows Terminal Here”
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="C:\Users\{YOUR_WINDOWS_USERNAME}\AppData\Local\Microsoft\WindowsApps\{YOUR_ICONS_FOLDER}\icon.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="\"C:\Users\{YOUR_WINDOWS_USERNAME}\AppData\Local\Microsoft\WindowsApps\wt.exe\""
- 将
{YOUR_WINDOWS_USERNAME}
替换为您的 Windows 用户名。 - 创建一个图标文件夹,将图标放在那里并将
{YOUR_ICONS_FOLDER}
替换为您的图标文件夹。 - 将其保存在
.reg
文件中并 运行 它。
另一个需要注意的事项 - 在 settings.json 我发现如果你不使用 "commandline": "C:/Program Files/Git/bin/bash.exe"
而是使用: "commandline": "C:/Program Files/Git/git-bash.exe"
Git shell 将在 Windows 终端之外的独立 window 中打开,而不是在选项卡上打开 - 这不是所需的行为。 此外,Windows 打开的终端中的选项卡也需要手动关闭,因为它会显示进程退出信息 - [进程退出代码 3221225786] 等
可能会让人头疼
因为大多数答案要么显示大量不相关的配置,要么不显示配置,我创建了自己的答案,试图更加集中。它主要基于profile settings reference and
步骤
打开PowerShell并输入
[guid]::NewGuid()
生成新的GUID。我们将在第 3 步使用它。> [guid]::NewGuid() Guid ---- a3da8d92-2f3f-4e36-9714-98876b6cb480
打开Windows终端的设置。 (CTRL+,)
将以下 JSON 对象添加到
profiles.list
。将guid
替换为您在步骤 1 中生成的{ "guid": "{a3da8d92-2f3f-4e36-9714-98876b6cb480}", "name": "Git Bash", "commandline": "\"%PROGRAMFILES%\Git\usr\bin\bash.exe\" -i -l", "icon": "%PROGRAMFILES%\Git\mingw64\share\git\git-for-windows.ico", "startingDirectory" : "%USERPROFILE%" },
备注
目前存在一个问题,您无法使用箭头键(和其他一些键)。不过,它似乎适用于最新的预览版。 (issue #6859)
不必指定
"startingDirectory" : "%USERPROFILE%"
according to the reference。但是,如果我不指定它,起始目录会因我最初启动终端的方式而有所不同。可以在
profiles.defaults
中指定适用于所有终端的设置。我建议在
profiles.defaults
中设置"antialiasingMode": "cleartype"
。您必须删除"useAcrylic"
(如果您按照其他一些答案的建议添加了它)才能使其正常工作。它提高了文本呈现的质量。但是,没有useAcrylic
就不能有透明背景。参见 issue #1298。如果您对光标有问题,可以尝试其他形状,例如
"cursorShape": "filledBox"
。有关详细信息,请参阅 cursor settings。
这就是我在配置文件中添加我的方式 json table,
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
"name": "Git",
"commandline": "C:/Program Files/Git/bin/bash.exe --login",
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
"startingDirectory": "%USERPROFILE%",
"hidden": false
}
新版本的 windows 终端可以通过其 GUI 进行配置。
Setting -> Add new
Under "command line" add the path -> path/to/Git/bin/bash.exe
现在是 2021 年 9 月,谢天谢地,最新的 Git Installation installer for Windows(我使用的是 2.33.0.2)已经为我们提供了这个选项,为了我们的懒惰(当然还有方便!)
请在安装Git之前先安装Windows终端,虽然我没有尝试相反的方式,但最好遵循合理的顺序。如果安装顺序不是这样,请让我知道更新此答案。
您可能会在安装阶段 Select 组件 的底部找到这个少数复选框,只需勾选那里的复选框即可。
settings.json
文件将自动添加 Git Bash 配置文件,并带有正确的 Git Bash 图标。我生成的 Git Bash 配置文件非常标准且最小。
{
"guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
"hidden": false,
"name": "Git Bash",
"source": "Git"
}
如果 Windows 终端是 运行,请关闭并再次启动以使 Git Bash 选项可见。
万一有人正在寻找 UI-Based 解决方案。这是:
转到终端的设置。
在右下角,找到“添加新配置文件”选项。 Screenshot for the Terminal's settings.
Select“新建空配置文件”
现在用您的 bash 信息填写字段。如果您的安装位置是默认位置,您可以使用这些:
- 姓名: Git-Bash
- 命令行: C:\Program Files\Git\bin\bash.exe
- 起始目录:[保留默认值]
- 图标:C:\程序Files\Git\mingw64\share\git\git-for-windows.ico
- 选项卡标题:Git-Bash Temrinal Settings completed 如果需要,您还可以浏览合适的文件。
- 点击保存按钮。
最终结果
致任何可能因缺失 bash 历史而受苦的人:
在已经打开的 git bash 中,尝试启动另一个 bash - 如果环境变量配置正确,它应该加载您的配置文件
如果是这种情况,您可以通过在启动时添加以下命令行使其自动化:
C:\progra~1\git\usr\bin\bash.exe --login -l -i -c /c/progra~1/git/usr/bin/bash.exe