R.A. Epigonos et al.

[git] 差分表示で色付けるには--color

git diffでコンソールに差分が表示されるが、このときに色をつけるとわかりやすい。

まずは単純に色をつける。git diff --colorを使う。

$ git diff --color 9f0652c71f8073a2ed4b5b0edb79b5ce91b98d8b..ab2888f06cd3427292e842b3292bd713de386fff po/ja.po
diff --git a/po/ja.po b/po/ja.po
index 1423782..a6eab39 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -1330,6 +1330,7 @@ msgstr "コマンドライン関数"
 msgid "<action> [<arguments>]"
 msgstr "<action> [<arguments>]"

+#, fuzzy
 msgid ""
 "list of actions:\n"
 "  return: simulate key \"enter\"\n"
@@ -1379,6 +1380,8 @@ msgid ""
 "  switch_active_buffer: switch to next merged buffer\n"
 "  switch_active_buffer_previous: switch to previous merged buffer\n"
 "  insert: insert text in command line\n"
+"  paste_start: start paste (bracketed paste mode)\n"
+"  paste_stop: stop paste (bracketed paste mode)\n"
 "\n"
 "This command is used by key bindings or plugins."
 msgstr ""
@@ -2592,7 +2595,15 @@ msgid "display space if nick mode is not (half)op/voice"
 msgstr "ニックモードが (half)op/voice でなければ空白を表示"

 msgid ""
-"max number of lines for paste without asking user (0 = disable this feature)"
+"enable terminal \"bracketed paste mode\" (not supported in all terminals/"
+"multiplexers): in this mode, pasted text is bracketed with control sequences "
+"so that WeeChat can differentiate pasted text from typed-in text \"(ESC[200~"
+"\", followed by the pasted text, followed by \"ESC[201~\")"
+msgstr ""
+
+#, fuzzy
+msgid ""
+"max number of lines for paste without asking user (-1 = disable this feature)"
 msgstr "ユーザへの確認無しにペーストできる行数の最大値 (0 = この機能を無効化)"

 msgid "prefix for error messages"
@@ -3387,9 +3398,10 @@ msgstr ""
 msgid "Bar \"%s\" updated"
 msgstr "バー \"%s\" がアップデートされました"

-#, c-format
-msgid "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No"
-msgstr "%s %d 行を貼り付けますか? [ctrl-Y] はい [ctrl-N] いいえ"
+#, fuzzy, c-format
+msgid "%sPaste %d line ? [ctrl-Y] Yes [ctrl-N] No"
+msgid_plural "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No"
+msgstr[0] "%s %d 行を貼り付けますか? [ctrl-Y] はい [ctrl-N] いいえ"

 msgid "Text search"
 msgstr "テキスト検索"

git diff --color-wordsを使うと、色をつけて、さらに違う部分に注目しやすく。

$ git diff --color-words 9f0652c71f8073a2ed4b5b0edb79b5ce91b98d8b..ab2888f06cd3427292e842b3292bd713de386fff po/ja.po
diff --git a/po/ja.po b/po/ja.po
index 1423782..a6eab39 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -1330,6 +1330,7 @@ msgstr "コマンドライン関数"
msgid "<action> [<arguments>]"
msgstr "<action> [<arguments>]"

#, fuzzy
msgid ""
"list of actions:\n"
"  return: simulate key \"enter\"\n"
@@ -1379,6 +1380,8 @@ msgid ""
"  switch_active_buffer: switch to next merged buffer\n"
"  switch_active_buffer_previous: switch to previous merged buffer\n"
"  insert: insert text in command line\n"
"  paste_start: start paste (bracketed paste mode)\n"
"  paste_stop: stop paste (bracketed paste mode)\n"
"\n"
"This command is used by key bindings or plugins."
msgstr ""
@@ -2592,7 +2595,15 @@ msgid "display space if nick mode is not (half)op/voice"
msgstr "ニックモードが (half)op/voice でなければ空白を表示"

msgid ""
"enable terminal \"bracketed paste mode\" (not supported in all terminals/"
"multiplexers): in this mode, pasted text is bracketed with control sequences "
"so that WeeChat can differentiate pasted text from typed-in text \"(ESC[200~"
"\", followed by the pasted text, followed by \"ESC[201~\")"
msgstr ""

#, fuzzy
msgid ""
"max number of lines for paste without asking user (0(-1 = disable this feature)"
msgstr "ユーザへの確認無しにペーストできる行数の最大値 (0 = この機能を無効化)"

msgid "prefix for error messages"
@@ -3387,9 +3398,10 @@ msgstr ""
msgid "Bar \"%s\" updated"
msgstr "バー \"%s\" がアップデートされました"

#, fuzzy, c-format
msgid "%sPaste %d line ? [ctrl-Y] Yes [ctrl-N] No"
msgid_plural "%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No"
msgstrmsgstr[0] "%s %d 行を貼り付けますか? [ctrl-Y] はい [ctrl-N] いいえ"

msgid "Text search"
msgstr "テキスト検索"

ログが流れる場合は、less -Rをつけて、色表示に対応したlessを使う。

$ git diff --color 9f0652c71f8073a2ed4b5b0edb79b5ce91b98d8b..ab2888f06cd3427292e842b3292bd713de386fff po/ja.po | less -R

リファレンス

  1. git diff 色 - Google 検索
  2. git diff "--color" - Google 検索
  3. git/git覚書 - TOBY SOFT wiki
  4. git diff --color-words べんり! - NaN days - subtech
  5. git diffをカラー表示 - うんたらかんたら日記
  6. @IT:カラー表示されたlsの出力をlessで表示するには

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-04-30T23:51:00+09:00
  2. Modified: 2010-04-30T23:51:00+09:00
  3. Generated: 2023-08-27T23:09:12+09:00