Skip to content

Instantly share code, notes, and snippets.

@naholyr
Created November 24, 2011 10:13
Show Gist options
  • Save naholyr/1391032 to your computer and use it in GitHub Desktop.
Save naholyr/1391032 to your computer and use it in GitHub Desktop.
Smart svn annotate for bash
# 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