我试图添加一个新的终端(Git Bash)到新的Windows终端。然而,我不能让它工作。
我尝试将profiles数组中的命令行属性更改为git-bash.exe,但没有运气。
有人知道怎么让它工作吗?
我试图添加一个新的终端(Git Bash)到新的Windows终端。然而,我不能让它工作。
我尝试将profiles数组中的命令行属性更改为git-bash.exe,但没有运气。
有人知道怎么让它工作吗?
当前回答
现在是2021年9月,谢天谢地,最新的Windows Git安装安装程序(我使用的是2.33.0.2)已经为我们覆盖了这个选项,为了我们的懒惰(当然也为了方便!)
请在安装Git之前先安装Windows终端,虽然我没有尝试过相反的方法,但最好遵循合理的顺序。如果安装顺序不是这样,请让我知道更新这个答案。
您可能会在安装阶段Select Components的底部发现这个少量复选框,只需勾选那里的复选框,就可以开始了。
设置。json文件将自动添加到Git Bash配置文件中,并带有正确的Git Bash图标。我生成的Git Bash配置文件非常标准和简洁。
{
"guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
"hidden": false,
"name": "Git Bash",
"source": "Git"
}
如果Windows终端正在运行,请关闭并再次启动,以便Git Bash选项可见。
其他回答
另一个需要注意的项目-在settings.json中 我发现如果你不使用 "commandline": "C:/Program Files/Git/bin/bash.exe"
取而代之的是: "commandline": "C:/Program Files/Git/ Git -bash.exe"
Git shell将在Windows终端之外的一个独立窗口中打开,而不是在一个选项卡中打开——这不是理想的行为。 此外,Windows终端中打开的选项卡也需要手动关闭,因为它将显示退出的进程信息-[退出的进程的代码为3221225786]等。
可能会让人头疼
对于那些可能错过bash历史的人: 在已经打开的git bash中,尝试启动另一个bash -如果env vars配置正确,应该会加载您的配置文件
如果这是你的情况,你可以通过在启动时添加以下命令行来自动化它:
C:\progra~1\git\usr\bin\bash.exe --login -l -i -c /c/progra~1/git/usr/bin/bash.exe
这就是我如何在profiles json表中添加我的,
{
"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
}
概述
用Ctrl+打开设置, 你需要将下面的一个配置文件选项(取决于你安装的git版本)追加到设置的“list”:部分。json文件:
{
"$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>
]
}
}
配置文件选项
取消注释命令行和图标的正确路径:
Git for Windows在%PROGRAMFILES% Git for Windows在%USERPROFILE% 如果你用勺子
{
"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
}
笔记
从https://github.com/microsoft/terminal/pull/2475开始创建自己的guid,这将不再生成。 guid可以在globals > defaultProfile中使用,所以你可以按下CtrlShiftT 或者启动一个Windows终端,它将默认启动bash
"defaultProfile" : "{00000000-0000-0000-ba54-000000000001}",
-l -i以确保加载.bash_profile 使用环境变量,这样它们就可以正确地映射到不同的系统。 目标git/bin/bash.exe,以避免产生额外的进程,根据进程资源管理器,与使用bin/bash或git-bash相比,每个进程节省约10MB
我的配置在https://gist.github.com/trajano/24f4edccd9a997fad8b4de29ea252cc8中使用Scoop
这是完整的答案(GitBash +配色方案+图标+上下文菜单)
设置默认配置文件:
"globals":
{
"defaultProfile" : "{00000000-0000-0000-0000-000000000001}",
...
添加giitbash配置文件
"profiles": [
{
"guid": "{00000000-0000-0000-0000-000000000001}",
"acrylicOpacity": 0.75,
"closeOnExit": true,
"colorScheme": "GitBash",
"commandline": "\"%PROGRAMFILES%\\Git\\usr\\bin\\bash.exe\" --login -i",
"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
}
]
添加giitbash配色方案
"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文件中并运行。