Git出力に色を割り当てるには?

Git出力に色を割り当てるには?

Git(または他のコマンド)の出力に色を付ける方法はありますか?

考慮する:

baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   app/models/message_type.rb
#
no changes added to commit (use "git add" and/or "git commit -a")
baller@Laptop:~/rails/spunky-monkey$ git add app/models

そして

baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   app/models/message_type.rb
#

出力は同じように見えますが、情報はまったく異なります。つまり、ファイルが送信の準備ができていない状態から準備済みの状態に変更されました。

出力に色を割り当てる方法はありますか?たとえば、ステージングされていないファイルは赤色で、ステージングされたファイルは緑色です。

それともChanges not staged for commit:赤と# Changes to be committed:緑もありますか?

Ubuntuで働いています。

編集:Google検索で本当にうまく機能する答えが公開されましたgit config --global --add color.ui true

しかし、コマンド出力に色を追加するより一般的な解決策はありますか?

ベストアンサー1

[color]~/.gitconfigたとえば、次を含むセクションを作成できます。

[color]
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = true
  pager = true

また、色付け方法を細かく制御できます。

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

[color "branch"]
  remote = yellow

これがあなたが始めることを願っています。もちろん、色をサポートする端末が必要です。

また見てくださいこの回答コマンドラインから直接シェーディングを追加する方法を学びます。

おすすめ記事