Colors
可以少保留彩色輸出嗎?
我可以減少不單色輸出嗎?
例如,輸出
git diff
是彩色的,但git diff | less
不是。
採用:
git diff --color=always | less -r
--color=always``git
即使輸出是管道(不是 tty),是否可以告訴輸出顏色程式碼。-r
是否可以解釋這些顏色程式碼和less
其他轉義序列。僅用於-R
ANSI 顏色程式碼。
另一種選擇是啟用顏色並使用“less -r”作為尋呼機。
git config --global color.ui true git config --global core.pager 'less -r'
這導致
[color] ui = true [core] pager = less -r
在你的 ~/.gitconfig
有關更多資訊,請參閱Pro Git 書籍。
可能的值
color.ui
可以在 git-config 的手冊頁中找到。的輸出man git-config | grep "color.ui$" -A8
是color.ui This variable determines the default value for variables such as color.diff and color.grep that control the use of color per command family. Its scope will expand as more commands learn configuration to set a default for the --color option. Set it to false or never if you prefer Git commands not to use color unless enabled explicitly with some other configuration or the --color option. Set it to always if you want all output not intended for machine consumption to use color, to true or auto (this is the default since Git 1.8.4) if you want such output to use color when written to the terminal.