Skip to content

Instantly share code, notes, and snippets.

@baztian
Created February 17, 2025 13:35
Show Gist options
  • Save baztian/84d1ff3a982e921f492454ebc9edcee8 to your computer and use it in GitHub Desktop.
Save baztian/84d1ff3a982e921f492454ebc9edcee8 to your computer and use it in GitHub Desktop.
Use diff-highlight instead the default diff for git if available
#!/bin/sh
# Git pager script for using diff-highlight
# Path to the diff-highlight script
DIFF_HIGHLIGHT="/usr/share/doc/git/contrib/diff-highlight/diff-highlight"
# Check if diff-highlight is available and executable
if [ -f "$DIFF_HIGHLIGHT" ]; then
# Use diff-highlight in the pipeline
perl "$DIFF_HIGHLIGHT" | less -r
else
# Fallback to regular less if diff-highlight is not available
less -r
fi
@baztian
Copy link
Author

baztian commented Feb 17, 2025

Use like this in your ~/.gitconfig

[interactive]
diffFilter = git-pager.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment