Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function usage
- {
- echo "Usage $0 <file name> <line> <context>"
- exit 1
- }
- code_file=$1
- lineno=$2
- context=$3
- if [ "$lineno" = "" ] ; then
- usage
- fi
- if [ "$context" = "" ] ; then
- context=6
- fi
- if [ "$context" -lt "4" ] ; then
- context=4
- fi
- if [ $(($context % 2 )) != "0" ] ; then
- context=$(($context + 1))
- fi
- start_line=$(($lineno - ($context / 2)))
- end_line=$(($lineno + ($context / 2)))
- cat -n $code_file | tail -n +$start_line | head -n $(($context + 1))
- echo
- echo ---
- echo
- hash=$(git blame $code_file -L $lineno,$lineno |cut -d " " -f 1)
- git --no-pager show $hash $code_file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement