dotfiles

My dotfiles: zsh, lf, sxiv, i3, ranger, mpd and more
Log | Files | Refs | Submodules | README | LICENSE

getbib (426B)


      1 #!/bin/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"