我试图添加一个新的终端(Git Bash)到新的Windows终端。然而,我不能让它工作。
我尝试将profiles数组中的命令行属性更改为git-bash.exe,但没有运气。
有人知道怎么让它工作吗?
我试图添加一个新的终端(Git Bash)到新的Windows终端。然而,我不能让它工作。
我尝试将profiles数组中的命令行属性更改为git-bash.exe,但没有运气。
有人知道怎么让它工作吗?
当前回答
这是完整的答案(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文件中并运行。
其他回答
对于那些可能错过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
概述
用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
将profiles参数更改为"commandline": "%PROGRAMFILES%\\Git\\bin\\bash.exe -l -i"
这对我来说是可行的,并且允许运行.bash_profile别名自动完成脚本。
我是这样做的:
添加“%programfiles%\Git\Bin”到你的路径 在档案上。将需要的命令行设置为"commandline": "sh——cd-to-home" 重新启动Windows终端
这对我很管用。
因为大多数答案要么显示大量不相关的配置,要么不显示配置,所以我创建了自己的答案,试图更集中。它主要是基于配置文件设置参考和阿基米德特拉哈诺的答案。
步骤
Open PowerShell and enter [guid]::NewGuid() to generate a new GUID. We will use it at step 3. > [guid]::NewGuid() Guid ---- a3da8d92-2f3f-4e36-9714-98876b6cb480 Open the settings of Windows Terminal. (CTRL+,) Add the following JSON object to profiles.list. Replace guid with the one you generated at step 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%" },
笔记
There is currently an issue that you cannot use your arrow keys (and some other keys). It seems to work with the latest preview version, though. (issue #6859) Specifying "startingDirectory" : "%USERPROFILE%" shouldn't be necessary according to the reference. However, if I don't specify it, the starting directory was different depending on how I started the terminal initially. Settings that shall apply to all terminals can be specified in profiles.defaults. I recommend to set "antialiasingMode": "cleartype" in profiles.defaults. You have to remove "useAcrylic" (if you have added it as suggested by some other answers) to make it work. It improves the quality of text rendering. However, you cannot have transparent background without useAcrylic. See issue #1298. If you have problems with the cursor, you can try another shape like "cursorShape": "filledBox". See cursor settings for more information.