Skip to content

Commit

Permalink
Hooks: Use pygmentize if available to visualize diff
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga committed Mar 30, 2020
1 parent 164826a commit 4d52761
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions misc/hooks/pre-commit-black
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ FILE_EXTS="py"

# Use pygmentize instead of cat to parse diff with highlighting.
# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac)
# READER="pygmentize -l diff"
READER=cat
PYGMENTIZE=`which pygmentize`
if [ ! -z "$PYGMENTIZE" ]; then
READER="pygmentize -l diff"
else
READER=cat
fi

##################################################################
# There should be no need to change anything below this line.
Expand Down
8 changes: 6 additions & 2 deletions misc/hooks/pre-commit-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc .java .glsl"

# Use pygmentize instead of cat to parse diff with highlighting.
# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac)
# READER="pygmentize -l diff"
READER=cat
PYGMENTIZE=`which pygmentize`
if [ ! -z "$PYGMENTIZE" ]; then
READER="pygmentize -l diff"
else
READER=cat
fi

##################################################################
# There should be no need to change anything below this line.
Expand Down

0 comments on commit 4d52761

Please sign in to comment.