Reputation:
I have a file.patch file generated from someone else. I want to review the patch file, but I would like to be able to apply my own git color config to the file.
I may not currently be in a git project directory and I may not even know what repo the patch file came from, but I just want to see basically context/additions/deletions colored with my normal git colors.
I'm looking for a pipeline solution rather than some external library. Something like:
git --please-color-this file.patch | less
Upvotes: 5
Views: 1525
Reputation: 3571
You can use Vim for this. Just open the file with vim file.patch
If you are worried about changing the file then use the -M
read-only flag vim -M file.patch
If you are trying to view it when reading from a pipe, you can tell vim to read from STDIN by using a -
as the file name.
diff -u file_a.py file_b.py | vim -M -
Upvotes: 2
Reputation: 119
colordiff < file.patch | less -R
The 'less' command is optional but I find it useful, e.g. for scrolling, searching.
Upvotes: 4
Reputation: 777
less
is not the program you're looking for, the colors are not stored in the file and less
doesn't understand the diff format. Instead, use a tool that understands the diff format, for instance text editors such as vscode
or vim
. The best program is the program you currently use for merge conflicts.
Upvotes: 0