Created
November 24, 2011 10:13
-
-
Save naholyr/1391032 to your computer and use it in GitHub Desktop.
Smart svn annotate for bash
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
# Usage: svn-annotate file [start-line [end-line]] | |
# Will output svn annotate on file + line numbers | |
# eventually cut depending on the given lines | |
function svn-annotate() { | |
# Work on a tempfile to avoid broken pipe | |
f=$(tempfile) | |
svn annotate "$1" > $f | |
CAT="cat -n" # Integrate line numbers, just remove the "-n" to disable | |
if [ "$2" == "" ]; then | |
# No start or end line | |
$CAT $f | |
else | |
if [ "$3" == "" ]; then | |
# Only start line | |
$CAT $f | tail -n $2 | |
else | |
# Start and end line | |
$CAT $f | head -n $3 | tail -n $(($3-$2+1)) | |
fi | |
fi | |
# Cleanup before leaving | |
rm -f $f | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment