Ubuntu上的Git bash [英] Git bash on Ubuntu
本文介绍了Ubuntu上的Git bash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何像Windows Bash一样将分支名称添加到控制台行中
How to add branch name into console line like it made in Windows Bash
foo@bar MINGW64 /d/_GitRepo/game (master)
$
并更改颜色主题
推荐答案
If you just want to show the current branch in the terminal command line, this site could help you https://techcommons.stanford.edu/topics/git/show-git-branch-bash-prompt
总结:
将此功能放在您的.bashrc
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
它提取当前分支.
然后编辑PS1变量的值,并调用使用$(parse_git_branch)
创建的函数.它看起来应该类似于:
It extracts the current branch.
Then edit value of the PS1 variable and call the function you created with $(parse_git_branch)
. It should look similar to this:
PS1="\h:\W \u$BLUE\$(parse_git_branch) $DEFAULT\$"
这篇关于Ubuntu上的Git bash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文