programing

Posh-Git에서 "git status" 출력 색상 변경

codeshow 2023. 4. 17. 22:11
반응형

Posh-Git에서 "git status" 출력 색상 변경

Posh-Git에서는 저장소에서 "git status"를 실행하면 변경 및 추적되지 않은 파일의 색상이 "normal" red로 설정하려고 하면 어두운 빨간색이 됩니다.저는 어두운 바탕의 콘솔이 있어서 어두운 빨간색은 읽기 어렵기 때문에 이것을 하고 싶습니다.

검색해 보니, 다음의 2개의 설정을 변경할 필요가 있는 것 같습니다.

  1. $GitPromptSettings에서 "Working ForgroundColor" 및 "Untracked ForgroundColor"를 "DarkRed"에서 "Red"로 변경합니다.

  2. git 설정에서 color.status.changed와 color.status.untracked를 빨간색으로 변경합니다.

제가 읽은 바로는 그것만 하면 되는데, "git status"의 결과는 여전히 어두운 빨간색으로 남아 있습니다.

다음은 내가 주장한 대로 설정했다는 것을 증명하기 위한 요약입니다. 누군가가 오류를 발견할 수 있습니다.

스크린샷

의 출력git status는 .disconfig 파일에 의해 제어됩니다.의 디폴트값changed그리고.untracked파일이 흐릿하다Red하지만 당신은 아마도Red Bold프롬프트에 표시되는 밝은 빨간색(기본값)입니다.

다음 항목을 .gitconfig 파일에 추가합니다.

[color]
    ui = true
[color "status"]
    changed = red bold
    untracked = red bold
    added = green bold

향후 이를 참조하는 다른 사용자의 경우 허용되는 색상은 다음과 같습니다.normal,black,red,green,yellow,blue,magenta,cyan,그리고.white또한 단일 옵션 수식자bold,dim,ul,blink, 또는reverse두 가지 색상을 지정하면 첫 번째 색상이 전경이 되고 두 번째 색상이 배경입니다.

여기서 DarkRed를 Red로 변경하는 방법은 콘솔 창 자체의 색상표 변경뿐입니다.내가 알기로는 git은 리스트에서 "첫 번째" 빨간색을 선택할 것이다(그것은 어둡다...).따라서 R 값을 늘리면 됩니다.

창(속성 -> 색상) 또는 레지스트리에서 직접 실행할 수 있습니다.프롬프트는 다른 이야기입니다.PS 색상 이름을 사용합니다.여기서 빨간색 = DarkRed가 아닌 빨간색...

목록에 있는 추적되지 않은 파일 및 수정된 파일의 색상을 읽기 쉬운 노란색으로 변경하려면 ~/.gitconfig 파일에 다음을 추가합니다.

[color "status"]
    untracked = bold yellow
    changed = bold yellow

또한 GitPrompt.ps1을 업데이트하여 추적되지 않은 노란색으로 표시하는 것도 좋은 방법입니다.

    UntrackedForegroundColor  = [ConsoleColor]::Yellow
    WorkingForegroundColor    = [ConsoleColor]::Yellow

편집: GitPrompt.ps1은 PowerShell posh-git 폴더에 있습니다.

@WarrenB의 답변에 가세합니다.상태 색상과 git diff(새 줄 및 삭제된 줄)의 색상을 변경하려면 .git/config 파일에 다음 항목이 있어야 합니다.

[color]
ui = true
[color "status"]
changed = red bold
untracked = red bold
added = green bold
[color "diff"]
old = red bold
new = green bold

「diff」옵션을 사용하면, 선명한(굵은) 빨강과 초록을 사용할 수 있습니다.참고 자료: https://git-scm.com/docs/git-config#git-config-colordiff

PowerShell posh-git 모듈 폴더에 있는 GitPrompt.ps1 파일의 소스를 수정하여 변경할 수 있습니다.같은 문제가 발생하여 이 파일의 30행 주위에 정의된 색상의 'Dark'를 삭제했습니다.

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**

이 Powershell 색상 목록도 유용합니다.

언급URL : https://stackoverflow.com/questions/18420139/changing-git-status-output-colors-in-posh-git

반응형