Skip to content

Instantly share code, notes, and snippets.

@bruce-ricard
Created February 17, 2023 19:00
Show Gist options
  • Select an option

  • Save bruce-ricard/322cb9135673fef163e935d8852abbc9 to your computer and use it in GitHub Desktop.

Select an option

Save bruce-ricard/322cb9135673fef163e935d8852abbc9 to your computer and use it in GitHub Desktop.
Git "love" alias for displaying logs for a specific line or line range
[alias]
love = "!f(){ \
if [[ -z $1 ]]; then echo 'You must pass a file name as the first parameter to \"love\"' >&2 ; exit 1; fi ;\
if [[ -z $2 ]]; then echo 'You must pass a line matcher as the second parameter to \"love\"' >&2 ; exit 1; fi ;\
FILE_NAME=$1 ;\
FIRST_LINE=$2 ;\
LAST_LINE=${3:-+1} ;\
git log -L ${FIRST_LINE},${LAST_LINE}:${FILE_NAME} ;\
};f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment