Skip to content

Commit

Permalink
added better error messaging for bibliography pasting
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed May 20, 2022
1 parent 4908524 commit 55e17eb
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions scripts/generate_temporary_bib.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#!/bin/zsh
# shellcheck disable=SC2154,SC2086
# shellcheck disable=SC2154
export PATH=/usr/local/bin:/opt/homebrew/bin/:$PATH
CSL=apa-6th-edition.csl

# citekey with @ prefix for pandoc
CITEKEY="@$*"

CSL=apa-6th-edition.csl
CITEKEY="@$*" # citekey with @ prefix for pandoc
LIBRARY="${bibtex_library_path/#\~/$HOME}"
DUMMYDOC="---\nnocite: |\n $CITEKEY\n---\n::: {#refs}\n:::"

echo -n "$DUMMYDOC" \
| pandoc --citeproc --read=markdown --write=plain --csl="assets/$CSL" --bibliography="$LIBRARY" \
| tr "\n" " " \
| tr -s " " \
| sed -E "s/^ //" \
| sed -E "s/ $//" \
| pbcopy
if ! which pandoc; then
echo -n "You need to install pandoc for this feature." | pbcopy
else
echo -n "$DUMMYDOC" \
| pandoc --citeproc --read=markdown --write=plain --csl="assets/$CSL" --bibliography="$LIBRARY" \
| tr "\n" " " \
| tr -s " " \
| sed -E "s/^ //" \
| sed -E "s/ $//" \
| pbcopy
fi

# paste
sleep 0.2
osascript -e 'tell application "System Events" to keystroke "v" using {command down}'

0 comments on commit 55e17eb

Please sign in to comment.