将 Git Bash 加入到 Windows Terminal
前言
本文主要讲述:
- 如何将
git bash加入到Windows Terminal - 将右键菜单
Git Bash Here改成用Windows Terminal包装的git bash
其实阅读过上一篇文章WindowsTerminal配置的小伙伴应该也知道如何配置这两项了,这篇是大概记录一下,主要讲解怎么修改git bash的注册表。
Windows Terminal 添加 git bash
在Windows Terminal的配置文件中添加一个session,名字叫GitBash,如何commandline如下:
1
"commandline" : "C:/Program Files/Git/bin/bash.exe --login"
不出意外,就可以在WindowsTerminal里面直接打开git bash了
修改GitBash的注册表
我上一篇文章说到在右键添加powershell,得加个注册表项HKEY_CLASSES_ROOT\Directory\Background\shell\powsh,所以反过来也可以得出,所有右键出现的项理论上都是在HKEY_CLASSES_ROOT\Directory\Background\shell这个下面。那我们就先打开注册表看看,Win+r打开运行窗口,输入regedit
然后找到HKEY_CLASSES_ROOT\Directory\Background\shell这个项,果不其然,有个git-shell,不出意外,就是我们要找的Git Bash的注册表。
修改git_shell下面的command的值,将原来的值"C:\Program Files\Git\git-bash.exe" "--cd=%v."改成C:\\Users\\[user_name]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -p GitBash即可。
右键看没什么区别,但是点击打开就可以看到是在Windows Terminal里面打开的git bash
若不想修改原来的Git Bash注册表,那我们也可以跟上一篇一样添加一个注册表项,如下:(其实也可以在刚刚的注册表编辑器上添加)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\gbwt]
@="Git Bash Here"
"Icon"="C:\\Users\\[user_name]\\AppData\\Local\\WindowsTerminal\\terminal.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\gbwt\command]
@="C:\\Users\\[user_name]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -p GitBash"
本文由作者按照
CC BY 4.0
进行授权


