dotfiles

beau's configuration files
git clone https://git.beauhilton.com/dotfiles.git
Log | Files | Refs | README

getbib (434B)


      1 #!/usr/bin/env sh
      2 [ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit
      3 
      4 if [ -f "$1" ]; then
      5 	# Try to get DOI from pdfinfo or pdftotext output.
      6 	doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
      7 	doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) ||
      8 	exit 1
      9 else
     10 	doi="$1"
     11 fi
     12 
     13 # Check crossref.org for the bib citation.
     14 curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"