Last active
August 29, 2015 13:57
-
-
Save kaushikgopal/9674859 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
# Get line number for file that needs to be added | |
argument = ARGV.pop | |
# do a git status and get the second argument | |
# filename = %x[git status -s | sed -n '#{argument}p'].split(" ", 2)[1] | |
filename = %x[git status -s | awk 'NR==#{argument}'].split(" ", 2)[1] # using awk baby! | |
system("git diff-index --quiet HEAD -- || clear; git diff --patch-with-stat #{filename}") | |
# here's a nice git status command to show you the file changed along with the line number | |
# git status -s | awk '{print NR,$0}' | awk -F: '{ print "\033[1;30m" $1 "\033[0m" }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment