Skip to content

Instantly share code, notes, and snippets.

@rindPHI
Created November 3, 2022 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rindPHI/bff52e25d70c8acd0b81eab84fad8fca to your computer and use it in GitHub Desktop.
Save rindPHI/bff52e25d70c8acd0b81eab84fad8fca to your computer and use it in GitHub Desktop.
A bash script for reformatting BibTeX bibliographies in place using BibTool. Takes special care to don't break cross references and handle German umlauts correctly.
tex.define {\"[1]=#1e}
tex.define {\ss=ss}
tex.define {\AE=AE}
tex.define {\OE=OE}
tex.define {\aa=aa}
tex.define {\AA=AA}
tex.define {\o=o}
tex.define {\O=O}
tex.define {\l=l}
tex.define {\L=L}
tex.define {\i=i}
tex.define {\j=j}
tex.define {\TeX=TeX }
tex.define {\LaTeX=LaTeX }
tex.define {\LaTeXe=LaTeX2e }
tex.define {\BibTeX=BibTeX }
tex.define {\AMSTeX=AMSTeX }
resource{biblatex}
#!/usr/bin/env bash
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
tmpfile=$(mktemp /tmp/bibtool.XXXXXX)
bibtool -f "{%-2n(author) # %-2n(editor)}-%2d(year)" -r "${SCRIPTPATH}/bibtool-umlauts.rsc" -r "${SCRIPTPATH}/sorting.rsc" -q "$1" > "${tmpfile}"
mv "${tmpfile}" "$1"
sort.format = {{%1.#s(crossref)a#z}$key}
sort.reverse = off
sort = on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment