Created
March 22, 2022 13:23
-
-
Save hrishikeshs/eee0f61e89cfd83cec4b4f3caf898490 to your computer and use it in GitHub Desktop.
git diff output that shows only the deleted lines from your diff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Written by Hrishikesh S | |
# | |
# Filters the output of git diff by showing you only the lines that are deletions. | |
# It doesn't display additions. | |
# | |
# Put this anywhere on your $PATH (~/bin is recommended). Then git will see it | |
# and you'll be able to do `git diff-deleted`. | |
# | |
set -e | |
# the stuff "\030" and stuff is for colorized output, ignore it. | |
git diff | awk '{if ($1 ~ /^[-]{1}/) {print "\033[31m" $0 "\033[0m"} else if($1 ~ /^[-]{3}/) {print "\033[1;32m" $0 "\033[0m"}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment