[英]Changing “git status” output colors in Posh-Git
In Posh-Git , when I run "git status" in a repository, the colors for changes and untracked files are dark red, when I have tried to configure them to be "normal" red. 在Posh-Git中 ,当我在存储库中运行“git status”时,当我尝试将它们配置为“正常”红色时,更改和未跟踪文件的颜色为深红色。 I want to do this because I have a console with a dark background, so dark red is difficult to read.
我想这样做是因为我有一个深色背景的控制台,所以深红色难以阅读。
I searched around, and there seem to be two configuration changes which I needed to make: 我四处搜索,似乎有两个配置更改我需要做:
Change "WorkingForegroundColor" and "UntrackedForegroundColor" from "DarkRed" to "Red" in $GitPromptSettings. 在$ GitPromptSettings中将“WorkingForegroundColor”和“UntrackedForegroundColor”从“DarkRed”更改为“Red”。
Change "color.status.changed" and "color.status.untracked" to red in git config. 在git config中将“color.status.changed”和“color.status.untracked”更改为红色。
From my reading, that's all I should need to do, and yet the results of "git status" remain dark red. 从我的阅读来看,这就是我应该做的所有事情,但“git status”的结果仍然是暗红色。
Here's a summary, to prove I set them as I claimed, and maybe someone can spot the error: 这是一个总结,以证明我按照我的说法设置它们,也许有人可以发现错误:
The output of git status
is controlled by your .gitconfig file. git status
的输出由.gitconfig文件控制。 The default for changed
and untracked
files is a dim Red
but you likely want Red Bold
which is the bright (default) red you have in the prompt. 已
changed
和untracked
文件的默认值为暗Red
但您可能需要Red Bold
,这是提示中的明亮(默认)红色。
Add the following to your .gitconfig file: 将以下内容添加到.gitconfig文件中:
[color]
ui = true
[color "status"]
changed = red bold
untracked = red bold
added = green bold
For anyone else referencing this in the future, the accepted colours are normal
, black
, red
, green
, yellow
, blue
, magenta
, cyan
, and white
as well a single optional modifier bold
, dim
, ul
, blink
, or reverse
. 对于将来引用此功能的任何其他人,可接受的颜色为
normal
颜色, black
, red
, green
, yellow
, blue
, magenta
, cyan
和white
以及单个可选修饰符bold
, dim
, ul
, blink
或reverse
。 If two colours are given the first is the foreground, and the second is the background. 如果给出两种颜色,则第一种是前景,第二种是背景。
There is only one way to change DarkRed to Red here: modify color scheme of console window itself. 这里只有一种方法可以将DarkRed更改为Red:修改控制台窗口本身的颜色方案。 As far as I know git will pick "first" red on the list (that happens to be dark...).
据我所知,git将在列表中选择“第一”红色(恰好是黑暗......)。 So just increase R value for it.
所以只需增加它的R值。
You can do it directly on window (Properties -> Colors) or in registry. 您可以直接在窗口(属性 - >颜色)或注册表中执行此操作。 Prompt is different story: it uses PS color names, where Red = Red, not DarkRed...
提示是不同的故事:它使用PS颜色名称,其中红色=红色,而不是DarkRed ......
To change the color of the listed untracked and modified files to the more readable yellow color, you can add this to your ~/.gitconfig file: 要将列出的未跟踪和修改文件的颜色更改为更易读的黄色,可以将其添加到〜/ .gitconfig文件中:
[color "status"]
untracked = bold yellow
changed = bold yellow
Also updating you GitPrompt.ps1 to show untracked as yellow is then probably a good idea: 同时更新GitPrompt.ps1以显示未跟踪黄色是一个好主意:
UntrackedForegroundColor = [ConsoleColor]::Yellow
WorkingForegroundColor = [ConsoleColor]::Yellow
Edit: GitPrompt.ps1 is found in the PowerShell posh-git folder. 编辑:在PowerShell posh-git文件夹中找到GitPrompt.ps1。
You can change these by modifying the source of the GitPrompt.ps1 file in the PowerShell posh-git module folder. 您可以通过修改PowerShell posh-git模块文件夹中的GitPrompt.ps1文件的源来更改这些。 I had the same issue and just removed the 'Dark' in the colors defined around line 30 in this file:
我有同样的问题,只是删除了此文件中第30行定义的颜色中的“暗”:
BeforeIndexForegroundColor= [ConsoleColor]::**Green**
BeforeIndexBackgroundColor= $Host.UI.RawUI.BackgroundColor
IndexForegroundColor = [ConsoleColor]::**Green**
IndexBackgroundColor = $Host.UI.RawUI.BackgroundColor
WorkingForegroundColor = [ConsoleColor]::**Red**
WorkingBackgroundColor = $Host.UI.RawUI.BackgroundColor
UntrackedText = ' !'
UntrackedForegroundColor = [ConsoleColor]::**Red**
This list of Powershell colors is also useful. 这个Powershell颜色列表也很有用。
In addition of @WarrenB answer. 除了@WarrenB的回答。 To change the color of status and the color of the git diff (of new lines and removed lines) you have to have this in your .git/config file:
要改变现状的颜色和 git的差异的颜色(新线和删除线),你必须有这个在你的.git / config文件:
[color]
ui = true
[color "status"]
changed = red bold
untracked = red bold
added = green bold
[color "diff"]
old = red bold
new = green bold
The "diff" option enables you the bright (bold) red and green colors. “diff”选项可以为您提供明亮(粗体)的红色和绿色。 Reference: https://git-scm.com/docs/git-config#git-config-colordiff
参考: https : //git-scm.com/docs/git-config#git-config-colordiff
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.