问题描述
我,如果我在一个git仓库中的PS1只显示该分支名
linux PS1 - 显示屏分会名存实亡内混帐回购协议,但我不能够得到它与我早先的PS1,这是集成
PS1 =[\\ D {%F} \\ @] \\ U / \\ W $
这显示,日期时间+用户名
[2015年8月20日下午11点38分] MTK
我试过
PS1 =[\\ D {%F} \\ @] \\ U / \\ W $(__ git_ps1)$
不过,我得到的错误
__ git_ps1:命令未找到
<空PS1>
什么办法让git的分支名与早期的细节,用于输出我PS1一起?
编辑:
我也试过
PS1 =[\\ D {%F} \\ @] \\ U / \\ W'$(__ git_ps1)$
不过,这给空行情始终,甚至内部的混帐回购协议。
的问题是从一个不同的。我是为了显示时间和日期+ git的分支(如果回购内部)。
PS1 =[\\ D {%F} \\ @] \\ U / \\ W \\ $(__ git_ps1)$
或
PS1 ='[\\ D {%F} \\ @] \\ U / \\ W $(__ git_ps1)$'
您必须逃离 $
,以便在每次执行,而不是只有一次。您可以使用单引号或逃避它这样做的一个 \\
。
I got to display just the branch name in the PS1 if I am in a git repolinux PS1 - display branch name only inside a git repo, but I am not able to get it integrated with my earlier PS1, which is
PS1="[\D{%F} \@] \u /\W $ "
this displays, datetime + username
[2015-08-20 11:38 PM] mtk
I tried
PS1="[\D{%F} \@] \u /\W $(__git_ps1) $ "
but, i get error
__git_ps1: command not found
<empty PS1>
Any way to get git branch name along with earlier details that my PS1 used to output?
EDIT:I also tried
PS1="[\D{%F} \@] \u /\W '$(__git_ps1)' $ "
but, this gives empty quotes always, even inside a git repo.
The question is different from that one. I was to display time and date + git branch (if its inside a repo).
PS1="[\D{%F} \@] \u /\W \$(__git_ps1) $ "
or
PS1='[\D{%F} \@] \u /\W $(__git_ps1) $ '
You must escape the $
in order to be executed each time, not only once. You can do so by using single quotes or escaping it with a \
.
这篇关于如何在PS1与其他输出显示混帐分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!