Created
May 24, 2021 13:03
-
-
Save hkarl/7b497f2cc659a55ae2d2ceef3d1dc32e to your computer and use it in GitHub Desktop.
How to process paper pile-exported bibfiles so that emacs / helm-bibtex / ivy-bibtex can work with them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the newest paperpile and fix the format | |
# Argument 1: Paperpile folder name to look for | |
# This is messy because paperpile insists on putting spaces in file names and gnu make can't handle that :-( | |
# This is also messy because paperpile has such a weird file format; not really compatible with ivy-bibtex / helm-bibtex in emacs. | |
sed_command1='s!file *= "All Papers!file = "/Users/hkarl/Google Drive/Paperpile/All Papers!' | |
sed_command2='s!,Starred Papers!!' | |
# find newest download file; careful with the spaces | |
# beware of: http://mywiki.wooledge.org/ParsingLs | |
download=`ls -t ~/Downloads/Paperpile*.bib | grep $1 | head -1` | |
if [ -z "${download}" ] | |
then | |
echo "no download file -- nothing to do" | |
else | |
echo "download file found: ${download}" | |
if [ -f paperpile.bib ] | |
then | |
echo "paperpile exists -- comparing date" | |
if [ "${download}" -nt paperpile.bib ] | |
then | |
echo "download is younger; copy it" | |
sed "${sed_command1}" "${download}" | sed "${sed_command2}" > paperpile.bib | |
else | |
echo "no newer download found" | |
fi | |
else | |
echo "download, but no local file" | |
sed "${sed_command1}" "${download}" | sed "${sed_command2}" > paperpile.bib | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment