简体   繁体   English

如何在Git For Windows bash shell中安装bash-git-prompt?

[英]How do i install bash-git-prompt in Git For Windows bash shell?

How would I go about installing bash-git-prompt in Git For Windows bash shell? 我将如何在Git For Windows bash shell中安装bash-git-prompt?

Docs at https://github.com/magicmonty/bash-git-prompt make mention of ~/.bashrc which I don't have. https://github.com/magicmonty/bash-git-prompt上的文档提到了〜/ .bashrc,而我没有。 I've found bash.bashrc in /etc and bash_profile.sh in /etc/profile.d which I suspect might be relevant. 我在/ etc中找到了bash.bashrc,在/etc/profile.d中找到了bash_profile.sh,我怀疑这可能是相关的。

Git bash already has its own git-prompt.sh which it uses to somehow provide its own git prompt, I suspect I have to somehow disable or replace this git prompt implementation with the one from https://github.com/magicmonty/bash-git-prompt , but I have no idea how. Git bash已经有自己的git-prompt.sh,它可以用来以某种方式提供自己的git提示,我怀疑我必须以某种方式禁用或替换此git提示实现,方法是使用https://github.com/magicmonty/bash -git-prompt ,但我不知道如何。

Does anyone know how to do this? 有谁知道如何做到这一点?

Step 1: 第1步:

Find where you install Git, then in directory Git/etc , clone repo bash-git-prompt : 找到安装Git的位置,然后在目录Git/etc ,克隆repo bash-git-prompt

git clone https://github.com/magicmonty/bash-git-prompt.git

Step 2: 第2步:

Open file bash.bashrc (in directory Git/etc ) using any editor, comment out all the code, add only three lines: 使用任何编辑器打开文件bash.bashrc (在目录Git/etc ),注释掉所有代码,仅添加三行:

GIT_PROMPT_ONLY_IN_REPO=1
GIT_PROMPT_THEME=Evermeet  # you can choose any theme you like, just select one in Git\etc\.bash-git-prompt\themes 
source /etc/.bash-git-prompt/gitprompt.sh

Save file, reopen your git bash window, Voila! 保存文件,重新打开git bash窗口,瞧! It's all done~ 都做完了

Problem: 问题:

If you find that the symbol in your bash window fails to display, you can solve it by: 如果发现bash窗口中的符号无法显示,可以通过以下方法解决:

right click on the title bar -> Options -> Text -> Font Select -> DejaVu Sans Mono

RefStrange character 参考奇怪的字符

The font limitation shows up in the default Ubuntu shell on Windows 10 as well but I was able to see the glyph characters by simply using DejaVu Mono https://dejavu-fonts.github.io/ . 字体限制也显示在Windows 10的默认Ubuntu外壳中,但是我仅使用DejaVu Mono https://dejavu-fonts.github.io/就能看到字形字符。 What @scotlynhatt means is download the font on windows, install it and then select it from the font menu for the WSL window (right click on the title bar -> properties -> font). @scotlynhatt的意思是在Windows上下载字体 ,安装该字体 ,然后从WSL窗口的字体菜单中选择它(右键单击标题栏->属性->字体)。

Just make your own .bashrc 只需制作自己的.bashrc

touch ~/.bashrc

Then go and edit with your favourite editor. 然后使用您最喜欢的编辑器进行编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM