Skip to content

Instantly share code, notes, and snippets.

@kleinschmidt
Last active October 30, 2016 20:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kleinschmidt/4b97fd87106c7472c67d to your computer and use it in GitHub Desktop.
Save kleinschmidt/4b97fd87106c7472c67d to your computer and use it in GitHub Desktop.
Make Mendeley, BibTeX, and apacite play nicely together by removing URL and month entries. Apacite lumps journal articles and newspaper/magazine articles in the same class, and always prints a month if it's provided. This gist has a shell script that strips this info out and a launchd handler that watches the auto-exported .bib file and runs the…
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>auto-clean-mendeley-library</string>
<key>ProgramArguments</key>
<array>
<string>/Users/dkleinschmidt/Documents/papers/clean-library-auto.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/dkleinschmidt/Documents/papers/library.bib</string>
</array>
</dict>
</plist>
#!/bin/bash
cd /Users/dkleinschmidt/Documents/papers
# remove month and url lines in bib entries
egrep -v '^(month|url)' > library-clean.bib < library.bib
# write a message to the log
/usr/bin/logger library.bib modified and cleaned
#!/bin/bash
# this whole solution was adapted from
# http://stackoverflow.com/questions/1515730/is-there-a-command-like-watch-or-inotifywait-on-the-mac
# you'll have to change the hard-coded locations to match whereever you put these
# files and Mendeley exports the .bib file.
# install the watcher using launchctl:
launchctl load /Users/dkleinschmidt/Documents/papers/clean-library-auto.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment