diff --git a/README.md b/README.md
index 3e5be5a..bed49cd 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Supercharged Citation Picker
![](https://img.shields.io/github/downloads/chrisgrieser/alfred-bibtex-citation-picker/total?label=Total%20Downloads&style=plastic) ![](https://img.shields.io/github/v/release/chrisgrieser/alfred-bibtex-citation-picker?label=Latest%20Release&style=plastic) [![](https://img.shields.io/badge/changelog-click%20here-FFE800?style=plastic)](./Changelog.md)
-A citation picker for academics that write in markdown. Using [Alfred](https://www.alfredapp.com/), it inserts citations from a BibTeX File in various formats, for example [Pandoc](https://pandoc.org/MANUAL.html#citation-syntax), [Multi-Markdown](https://fletcher.github.io/MultiMarkdown-6/syntax/citation.html) or [Latex](https://www.overleaf.com/learn/latex/Biblatex_citation_styles).
+A citation picker and minimalistic reference manager for [Alfred](https://www.alfredapp.com/). Uses a BibTeX File and supports various formats like [Pandoc Markdown](https://pandoc.org/MANUAL.html#citation-syntax), [Multi-Markdown](https://fletcher.github.io/MultiMarkdown-6/syntax/citation.html) or [LaTeX](https://www.overleaf.com/learn/latex/Biblatex_citation_styles).
@@ -12,7 +12,7 @@ A citation picker for academics that write in markdown. Using [Alfred](https://w
- __Feature-rich:__ paste single-entry bibliographies, open URLs, open or create literature notes, attach PDFs, search for `.csl` files online, and more.
- __Blazingly Fast:__ considerably quicker than any other citation pickers (~200 ms to fully reload a library with ~4000 entries).
- __Simple Installation:__ no dependencies, no required plugins, no setup. Just enter the path to your `.bib` file.
-- __Minimalistic reference manager__: add or remove entries the BibTeX library, automatically rename and file PDFs, parse single entries, and more.
+- __Minimalistic reference manager__: add or remove entries the BibTeX library, automatically rename and file PDFs, and more.
- __Obsidian integration:__ When located in an [Obsidian](https://obsidian.md/) vault, literature notes are automatically opened or created in Obsidian instead of the default markdown app.
## Table of Contents
@@ -97,11 +97,12 @@ If there is a citation syntax that is commonly used, or if you want to improve s
### Bibliography Actions
- `⇧ + ↵`: Reveal the entry in Zotero, neovim, BibDesk, VS Code, or Sublime, depending on the setting in the workflow configuration.
- `⌘⌥ + ↵`: Paste the full bibliographic entry in the APA 6th Style (requires [Pandoc](https://pandoc.org/installing.html)).
-- `⌘ + L`: Preview the (unabridged) title, abstract, and list of keywords in Large Type.
+- `⌘ + L`: Preview the (unabridged) title, abstract, and list of keywords in Large type.
- `⌘fn + ↵`: Delete the entry from the BibTeX library. (⚠️ This feature is untested with BibTeX files created with apps other than BibDesk and Bookends. [Create an issue](https://github.com/chrisgrieser/alfred-bibtex-citation-picker/issues) for problems with other apps.)
- `universal action` or `hotkey`: Uses the selected __DOI__, __ISBN__, or __URL containing a DOI__ to add a new entry to the library.
- *Experimental:* A second universal action can be used to parse & add a bibliographic entry. Requires [anystyle](https://github.com/inukshuk/anystyle).
- - The new entry is added to your library, with a correctly formatted and unique citekey. Afterward, the entry is opened in the app specified in `open_entries_in`.
+ - The new entry is added to your library, with a correctly formatted and unique citekey. Afterward, the entry is opened.
+- `file action`: Use the "Add Entry and Auto-file" action on a PDF file that includes a DOI. The DOI is automatically retrieved from the PDF, the entry added to the library, and the PDF auto-filed (see [PDF Management Actions](#pdf-management-actions)). Requires [pdfgrep](https://pdfgrep.org/).
> __Note__
> Adding or removing entries does __not__ work with the [BetterBibTeX Zotero Plugin](https://retorque.re/zotero-better-bibtex/) since the plugin only does a one-way-sync (Zotero ➞ BibTeX file), meaning any changes to the `.bib` file are not reflected in Zotero.
diff --git a/get-doi-from-pdf.sh b/get-doi-from-pdf.sh
new file mode 100755
index 0000000..1227d72
--- /dev/null
+++ b/get-doi-from-pdf.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env zsh
+export PATH=/usr/local/lib:/usr/local/bin:/opt/homebrew/bin/:$PATH
+
+if ! command -v pdfgrep &>/dev/null; then echo "pdfgrep not installed." && exit 1; fi
+
+pdf="$*"
+pdfgrep --page-range=1,4 --max-count=1 "doi" "$pdf" || echo -n "No DOI found in first 4 pages."
diff --git a/info.plist b/info.plist
index 9f8432c..9210904 100644
--- a/info.plist
+++ b/info.plist
@@ -252,15 +252,42 @@
- 4A969BD2-B35E-426A-A692-429F0901DF1C
+ 4D0EDD75-8E26-4099-956B-50637A6F0C93
destinationuid
- AF09AE5D-C351-4190-8AA6-B1924D88B22F
+ 85B36033-B322-42EB-AE72-6A7EA59B184B
+ modifiers
+ 0
+ modifiersubtext
+
+ sourceoutputuid
+ 14FB4C6A-E89A-4DBE-8F36-87C64E7B4314
+ vitoclose
+
+
+
+ destinationuid
+ 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
+ 4DA0A4D6-F21E-433C-9EB1-C781B01CA932
+
+
+ destinationuid
+ 7E602D21-0A78-4DC6-A807-28A5602897C8
modifiers
0
modifiersubtext
+ sourceoutputuid
+ 82516F68-263B-4711-BDF5-17C63D4EB228
vitoclose
@@ -387,7 +414,7 @@
destinationuid
- 346A58DA-B1B4-4F03-8F05-20B42A4EF996
+ 9503EA26-7397-4C25-9DB0-EA2ED9821861
modifiers
0
modifiersubtext
@@ -409,6 +436,19 @@
+ 85B36033-B322-42EB-AE72-6A7EA59B184B
+
+
+ destinationuid
+ 2DC90122-FC40-44CA-8F59-E3C16AC99651
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
8B51C1A0-EAD2-457B-A532-6CC16C7F015E
@@ -483,6 +523,19 @@
+ 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
+
+
+ destinationuid
+ 254C2241-0AE4-4F52-A073-16E3DEFC9384
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
A1A6DEC2-1AF1-4110-9DA9-01400A1902FF
@@ -509,6 +562,19 @@
+ B2C01CFD-4663-47E1-9D0E-8061943CDBC5
+
+
+ destinationuid
+ F46030BA-A511-425D-99AB-40C220A6F0F3
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
B8AEF220-7CBC-4D07-BA5F-D28094B3D4B4
@@ -622,23 +688,34 @@
- BC0E1F77-0045-40D3-845C-946E6BCFC90D
+ B9438E50-CC87-44AC-9F19-A9A6ADCF7F09
destinationuid
- 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
+ AF09AE5D-C351-4190-8AA6-B1924D88B22F
modifiers
0
modifiersubtext
- sourceoutputuid
- 14FB4C6A-E89A-4DBE-8F36-87C64E7B4314
vitoclose
destinationuid
- 254C2241-0AE4-4F52-A073-16E3DEFC9384
+ 4DA0A4D6-F21E-433C-9EB1-C781B01CA932
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
+ BC0E1F77-0045-40D3-845C-946E6BCFC90D
+
+
+ destinationuid
+ 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
modifiers
0
modifiersubtext
@@ -650,7 +727,7 @@
destinationuid
- 4A969BD2-B35E-426A-A692-429F0901DF1C
+ B9438E50-CC87-44AC-9F19-A9A6ADCF7F09
modifiers
0
modifiersubtext
@@ -726,6 +803,19 @@
+ F46030BA-A511-425D-99AB-40C220A6F0F3
+
+
+ destinationuid
+ 4D0EDD75-8E26-4099-956B-50637A6F0C93
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
F4AE9C32-4A15-421F-A8FE-C71500135BA3
@@ -1160,25 +1250,6 @@ JSON.stringify({ 'items': entry_array });
version
2
-
- config
-
- autopaste
-
- clipboardtext
- {var:_format_citation_start}{query}{var:_format_citation_end}
- ignoredynamicplaceholders
-
- transient
-
-
- type
- alfred.workflow.output.clipboard
- uid
- CB4D33E2-A031-4542-A640-3B73D66EE39E
- version
- 3
-
config
@@ -1210,6 +1281,25 @@ JSON.stringify({ 'items': entry_array });
version
2
+
+ config
+
+ autopaste
+
+ clipboardtext
+ {var:_format_citation_start}{query}{var:_format_citation_end}
+ ignoredynamicplaceholders
+
+ transient
+
+
+ type
+ alfred.workflow.output.clipboard
+ uid
+ CB4D33E2-A031-4542-A640-3B73D66EE39E
+ version
+ 3
+
config
@@ -1265,27 +1355,6 @@ JSON.stringify({ 'items': entry_array });
version
2
-
- config
-
- lastpathcomponent
-
- onlyshowifquerypopulated
-
- removeextension
-
- text
-
- title
- ⚠️ {query}
-
- type
- alfred.workflow.output.notification
- uid
- 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
- version
- 1
-
config
@@ -1303,25 +1372,6 @@ JSON.stringify({ 'items': entry_array });
version
1
-
- config
-
- autopaste
-
- clipboardtext
- {query}
- ignoredynamicplaceholders
-
- transient
-
-
- type
- alfred.workflow.output.clipboard
- uid
- 83A9C045-9885-4C76-B88D-DAC01E9528C0
- version
- 3
-
config
@@ -1352,8 +1402,8 @@ JSON.stringify({ 'items': entry_array });
variables
- parseText
- false
+ mode
+ id
type
@@ -1366,32 +1416,36 @@ JSON.stringify({ 'items': entry_array });
config
- argument
- {var:_format_citekey_prefix}{query}{var:_format_citekey_suffix}
- passthroughargument
+ autopaste
+
+ clipboardtext
+ {query}
+ ignoredynamicplaceholders
+
+ transient
- variables
-
type
- alfred.workflow.utility.argument
+ alfred.workflow.output.clipboard
uid
- A1A6DEC2-1AF1-4110-9DA9-01400A1902FF
+ 83A9C045-9885-4C76-B88D-DAC01E9528C0
version
- 1
+ 3
config
- soundname
- Basso
- systemsound
-
+ argument
+ {var:_format_citekey_prefix}{query}{var:_format_citekey_suffix}
+ passthroughargument
+
+ variables
+
type
- alfred.workflow.output.playsound
+ alfred.workflow.utility.argument
uid
- 254C2241-0AE4-4F52-A073-16E3DEFC9384
+ A1A6DEC2-1AF1-4110-9DA9-01400A1902FF
version
1
@@ -1480,8 +1534,8 @@ JSON.stringify({ 'items': entry_array });
variables
- parseText
- true
+ mode
+ parse
type
@@ -1491,27 +1545,6 @@ JSON.stringify({ 'items': entry_array });
version
1
-
- config
-
- matchmode
- 1
- matchstring
- \n$
- regexcaseinsensitive
-
- regexmultiline
-
- replacestring
-
-
- type
- alfred.workflow.utility.replace
- uid
- 4A969BD2-B35E-426A-A692-429F0901DF1C
- version
- 2
-
config
@@ -1545,31 +1578,20 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
config
- argumenttrimmode
- 0
- argumenttype
- 1
- fixedorder
-
- items
- [{"title":"✍️ Search & Download Citation Styles","arg":"csl","subtitle":".csl files"},{"title":"💬 Change Citation Format","arg":"change_format","subtitle":"Pandoc, MMD, Latex, Wikilinks, Tags, Eta template"},{"title":"🔁 Force Buffer Reload","arg":"buffer_reload","subtitle":"for debugging"},{"title":"❓Citation Picker Actions","arg":"cheatsheet","subtitle":"Cheatsheet"}]
- keyword
- scp
- matchmode
- 0
- runningsubtext
-
- subtext
-
- title
- Supercharged Citation Picker
- withspace
+ argument
+ {query}
+ passthroughargument
+ variables
+
+ mode
+ id+autofile
+
type
- alfred.workflow.input.listfilter
+ alfred.workflow.utility.argument
uid
- 04E17547-EDD2-4C44-9F41-F15391DD8775
+ 85B36033-B322-42EB-AE72-6A7EA59B184B
version
1
@@ -1585,33 +1607,164 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
scriptargtype
1
scriptfile
- scripts/open-entry.sh
+ get-doi-from-pdf.sh
type
8
type
alfred.workflow.action.script
uid
- AF09AE5D-C351-4190-8AA6-B1924D88B22F
+ F46030BA-A511-425D-99AB-40C220A6F0F3
version
2
config
- externaltriggerid
- citation-picker-loop
- passinputasargument
+ acceptsmulti
+ 0
+ filetypes
+
+ com.adobe.pdf
+
+ name
+ Add Entry & Autofile
+
+ type
+ alfred.workflow.trigger.action
+ uid
+ B2C01CFD-4663-47E1-9D0E-8061943CDBC5
+ version
+ 1
+
+
+ config
+
+ soundname
+ Basso
+ systemsound
+
+
+ type
+ alfred.workflow.output.playsound
+ uid
+ 254C2241-0AE4-4F52-A073-16E3DEFC9384
+ version
+ 1
+
+
+ config
+
+ lastpathcomponent
- passvariables
+ onlyshowifquerypopulated
+
+ removeextension
+
+ text
+
+ title
+ ⚠️ {query}
+
+ type
+ alfred.workflow.output.notification
+ uid
+ 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
+ version
+ 1
+
+
+ config
+
+ conditions
+
+
+ inputstring
+
+ matchcasesensitive
+
+ matchmode
+ 1
+ matchstring
+ No DOI found in first 4 pages.
+ outputlabel
+ found
+ uid
+ 14FB4C6A-E89A-4DBE-8F36-87C64E7B4314
+
+
+ elselabel
+ not found
+ hideelse
+
+
+ type
+ alfred.workflow.utility.conditional
+ uid
+ 4D0EDD75-8E26-4099-956B-50637A6F0C93
+ version
+ 1
+
+
+ config
+
+ concurrently
+
+ escaping
+ 0
+ script
+
+ scriptargtype
+ 1
+ scriptfile
+ scripts/open-entry.sh
+ type
+ 8
+
+ type
+ alfred.workflow.action.script
+ uid
+ AF09AE5D-C351-4190-8AA6-B1924D88B22F
+ version
+ 2
+
+
+ type
+ alfred.workflow.utility.junction
+ uid
+ B9438E50-CC87-44AC-9F19-A9A6ADCF7F09
+ version
+ 1
+
+
+ config
+
+ conditions
+
+
+ inputstring
+ {var:mode}
+ matchcasesensitive
+
+ matchmode
+ 0
+ matchstring
+ id+autofile
+ outputlabel
+
+ uid
+ 82516F68-263B-4711-BDF5-17C63D4EB228
+
+
+ elselabel
+ else
+ hideelse
- workflowbundleid
- self
type
- alfred.workflow.output.callexternaltrigger
+ alfred.workflow.utility.conditional
uid
- 7416BB08-7009-4A47-B833-524B2C3BDB55
+ 4DA0A4D6-F21E-433C-9EB1-C781B01CA932
version
1
@@ -1651,6 +1804,56 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
version
1
+
+ config
+
+ externaltriggerid
+ citation-picker-loop
+ passinputasargument
+
+ passvariables
+
+ workflowbundleid
+ self
+
+ type
+ alfred.workflow.output.callexternaltrigger
+ uid
+ 7416BB08-7009-4A47-B833-524B2C3BDB55
+ version
+ 1
+
+
+ config
+
+ argumenttrimmode
+ 0
+ argumenttype
+ 1
+ fixedorder
+
+ items
+ [{"title":"✍️ Search & Download Citation Styles","arg":"csl","subtitle":".csl files"},{"title":"💬 Change Citation Format","arg":"change_format","subtitle":"Pandoc, MMD, Latex, Wikilinks, Tags, Eta template"},{"title":"🔁 Force Buffer Reload","arg":"buffer_reload","subtitle":"for debugging"},{"title":"❓Citation Picker Actions","arg":"cheatsheet","subtitle":"Cheatsheet"}]
+ keyword
+ scp
+ matchmode
+ 0
+ runningsubtext
+
+ subtext
+
+ title
+ Supercharged Citation Picker
+ withspace
+
+
+ type
+ alfred.workflow.input.listfilter
+ uid
+ 04E17547-EDD2-4C44-9F41-F15391DD8775
+ version
+ 1
+
config
@@ -1725,6 +1928,56 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
version
1
+
+ config
+
+ alignment
+ 0
+ backgroundcolor
+
+ fadespeed
+ 0
+ fillmode
+ 0
+ font
+
+ ignoredynamicplaceholders
+
+ largetypetext
+ {query}
+ textcolor
+
+ wrapat
+ 50
+
+ type
+ alfred.workflow.output.largetype
+ uid
+ 9503EA26-7397-4C25-9DB0-EA2ED9821861
+ version
+ 3
+
+
+ config
+
+ browser
+
+ skipqueryencode
+
+ skipvarencode
+
+ spaces
+
+ url
+
+
+ type
+ alfred.workflow.action.openurl
+ uid
+ 30006A6B-EAF9-4531-8694-5E878A0FB80E
+ version
+ 1
+
config
@@ -1799,27 +2052,6 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
version
1
-
- config
-
- browser
-
- skipqueryencode
-
- skipvarencode
-
- spaces
-
- url
-
-
- type
- alfred.workflow.action.openurl
- uid
- 30006A6B-EAF9-4531-8694-5E878A0FB80E
- version
- 1
-
config
@@ -2083,6 +2315,26 @@ In some cases, you may need to restart Alfred for this change to take effect.
version
1
+
+ config
+
+ argument
+
+ passthroughargument
+
+ variables
+
+ citekey
+ {query}
+
+
+ type
+ alfred.workflow.utility.argument
+ uid
+ 3FA32575-5519-475C-AFED-6182B53063A6
+ version
+ 1
+
config
@@ -2132,26 +2384,6 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
version
2
-
- config
-
- argument
-
- passthroughargument
-
- variables
-
- citekey
- {query}
-
-
- type
- alfred.workflow.utility.argument
- uid
- 3FA32575-5519-475C-AFED-6182B53063A6
- version
- 1
-
config
@@ -2278,16 +2510,16 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
xpos
290
ypos
- 1275
+ 1370
03FDB341-D261-4E25-B0A4-53ECD86664EC
colorindex
- 5
+ 9
xpos
- 190
+ 235
ypos
- 630
+ 585
04E17547-EDD2-4C44-9F41-F15391DD8775
@@ -2298,16 +2530,16 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
xpos
30
ypos
- 785
+ 990
09C552E1-E9BA-418A-931E-D134C3FA1A7F
colorindex
- 5
+ 9
xpos
- 185
+ 235
ypos
- 515
+ 470
0F42598F-2E5E-474F-8E68-9FC22069FF39
@@ -2327,7 +2559,7 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
xpos
325
ypos
- 920
+ 1015
10ACA015-64F3-4D2E-A659-213C5A665FDE
@@ -2336,9 +2568,9 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
note
Delete Entry
xpos
- 1145
+ 1235
ypos
- 1400
+ 1455
113F2026-78AB-41BA-8836-6145DE94CBEF
@@ -2347,18 +2579,18 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
note
open PDF
xpos
- 940
+ 1030
ypos
- 1535
+ 1590
1B72EC4E-33E7-4144-B43B-3037510ADA3A
colorindex
2
xpos
- 1355
+ 1445
ypos
- 1355
+ 1410
1C0964D1-AA81-478A-B406-28E96DDD9E82
@@ -2387,9 +2619,9 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
colorindex
1
xpos
- 550
+ 620
ypos
- 530
+ 830
2A483E3B-2BAB-408A-9759-4C0F65D760CF
@@ -2398,7 +2630,7 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
xpos
715
ypos
- 1045
+ 1140
2D72874E-4A27-4A0C-98B3-15EFBEBE1031
@@ -2407,7 +2639,7 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
xpos
290
ypos
- 1150
+ 1245
2DC90122-FC40-44CA-8F59-E3C16AC99651
@@ -2416,9 +2648,9 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
note
create new entry
xpos
- 290
+ 325
ypos
- 600
+ 555
30006A6B-EAF9-4531-8694-5E878A0FB80E
@@ -2427,9 +2659,9 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
note
open URL/DOI
xpos
- 940
+ 1030
ypos
- 1120
+ 1175
346A58DA-B1B4-4F03-8F05-20B42A4EF996
@@ -2438,9 +2670,9 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
note
error
xpos
- 1110
+ 1200
ypos
- 915
+ 970
387C2AA0-E567-46B7-96C2-46E4BD95733B
@@ -2449,7 +2681,7 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
xpos
30
ypos
- 485
+ 440
3E233EB1-E0B2-48CC-9E6F-A5CAFDFD26AD
@@ -2469,7 +2701,7 @@ to set a hotkey for the citaiton picker.
colorindex
2
xpos
- 915
+ 1005
ypos
1430
@@ -2482,7 +2714,7 @@ to set a hotkey for the citaiton picker.
xpos
300
ypos
- 1015
+ 1110
4771A40C-E741-46C5-93EF-82CEB4BD23D8
@@ -2493,16 +2725,27 @@ to set a hotkey for the citaiton picker.
ypos
15
- 4A969BD2-B35E-426A-A692-429F0901DF1C
+ 4D0EDD75-8E26-4099-956B-50637A6F0C93
+
+ colorindex
+ 9
+ note
+ DOI
+ xpos
+ 325
+ ypos
+ 835
+
+ 4DA0A4D6-F21E-433C-9EB1-C781B01CA932
colorindex
9
note
- remove \n
+ id+autofile
xpos
- 565
+ 960
ypos
- 645
+ 925
52B9C3DF-F265-4201-9508-55BA584F851F
@@ -2511,7 +2754,7 @@ to set a hotkey for the citaiton picker.
xpos
575
ypos
- 1150
+ 1245
55B921A5-4319-4B5C-A06B-66427377E219
@@ -2520,7 +2763,7 @@ to set a hotkey for the citaiton picker.
xpos
85
ypos
- 1080
+ 1175
57D40C47-4A2C-47A2-9E7A-A3CC8C3FB671
@@ -2529,7 +2772,7 @@ to set a hotkey for the citaiton picker.
xpos
235
ypos
- 1180
+ 1275
5A83CD14-6282-49D4-9482-F89DC21A185F
@@ -2538,18 +2781,18 @@ to set a hotkey for the citaiton picker.
note
open/create Literature Note
xpos
- 940
+ 1030
ypos
- 1255
+ 1310
5B6D763D-7B64-4EA7-BCE2-0929216BA8D2
colorindex
2
xpos
- 1350
+ 1440
ypos
- 1470
+ 1525
5DDAD2E1-5F9B-4181-99AB-45A86844AA87
@@ -2571,7 +2814,7 @@ to set a hotkey for the citaiton picker.
xpos
30
ypos
- 600
+ 555
5F683C78-5D0B-4A39-B3FF-37ABA8DA0D73
@@ -2589,7 +2832,7 @@ to set a hotkey for the citaiton picker.
xpos
235
ypos
- 1305
+ 1400
7416BB08-7009-4A47-B833-524B2C3BDB55
@@ -2598,7 +2841,7 @@ to set a hotkey for the citaiton picker.
xpos
395
ypos
- 890
+ 985
7E602D21-0A78-4DC6-A807-28A5602897C8
@@ -2607,18 +2850,18 @@ to set a hotkey for the citaiton picker.
note
autofile
xpos
- 940
+ 1030
ypos
- 985
+ 1040
7FED238F-6F1B-440B-9FB3-5D9B520D67BF
colorindex
1
xpos
- 1105
+ 1195
ypos
- 1535
+ 1590
824D0711-2DC5-46B0-8EA1-BD0A74DF5AAA
@@ -2627,7 +2870,7 @@ to set a hotkey for the citaiton picker.
xpos
440
ypos
- 1275
+ 1370
83A9C045-9885-4C76-B88D-DAC01E9528C0
@@ -2640,6 +2883,15 @@ to set a hotkey for the citaiton picker.
ypos
485
+ 85B36033-B322-42EB-AE72-6A7EA59B184B
+
+ colorindex
+ 9
+ xpos
+ 235
+ ypos
+ 690
+
8B51C1A0-EAD2-457B-A532-6CC16C7F015E
colorindex
@@ -2649,14 +2901,21 @@ to set a hotkey for the citaiton picker.
ypos
25
+ 9503EA26-7397-4C25-9DB0-EA2ED9821861
+
+ xpos
+ 1265
+ ypos
+ 1140
+
9608AE94-464B-4B17-A1CA-71855DDB207D
colorindex
2
xpos
- 1285
+ 1375
ypos
- 1500
+ 1555
96FCE9BC-5201-4357-9B63-588F73AEF5F3
@@ -2665,7 +2924,7 @@ to set a hotkey for the citaiton picker.
note
paste single bibliography
xpos
- 940
+ 1030
ypos
685
@@ -2687,16 +2946,16 @@ to set a hotkey for the citaiton picker.
xpos
580
ypos
- 1275
+ 1370
9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
colorindex
1
xpos
- 550
+ 480
ypos
- 420
+ 830
A1A6DEC2-1AF1-4110-9DA9-01400A1902FF
@@ -2716,10 +2975,21 @@ to set a hotkey for the citaiton picker.
note
Open Entry
xpos
- 940
+ 1030
ypos
835
+ B2C01CFD-4663-47E1-9D0E-8061943CDBC5
+
+ colorindex
+ 5
+ note
+ Add entry & autofile
+ xpos
+ 30
+ ypos
+ 815
+
B8AEF220-7CBC-4D07-BA5F-D28094B3D4B4
colorindex
@@ -2731,14 +3001,23 @@ to set a hotkey for the citaiton picker.
ypos
120
+ B9438E50-CC87-44AC-9F19-A9A6ADCF7F09
+
+ colorindex
+ 9
+ xpos
+ 915
+ ypos
+ 865
+
BC0E1F77-0045-40D3-845C-946E6BCFC90D
colorindex
9
xpos
- 445
+ 465
ypos
- 620
+ 575
C12D9E2C-7B53-4F1C-A0E4-009E784AE888
@@ -2751,7 +3030,7 @@ to set a hotkey for adding a DOI or ISBN
xpos
30
ypos
- 320
+ 260
C64ACAF0-66C8-48A8-A3C4-B55C7E282697
@@ -2808,14 +3087,25 @@ to set a hotkey for adding a DOI or ISBN
ypos
340
+ F46030BA-A511-425D-99AB-40C220A6F0F3
+
+ colorindex
+ 9
+ note
+ get doi from PDF
+ xpos
+ 180
+ ypos
+ 815
+
F4AE9C32-4A15-421F-A8FE-C71500135BA3
colorindex
2
xpos
- 1000
+ 1090
ypos
- 1400
+ 1455
FC604ACD-94BE-4F8B-B73C-8475943837C7
@@ -2824,16 +3114,16 @@ to set a hotkey for adding a DOI or ISBN
xpos
440
ypos
- 1150
+ 1245
FCCA3147-A52B-4254-938A-C8EFA2FF7933
colorindex
1
xpos
- 1255
+ 1345
ypos
- 915
+ 970
userconfigurationconfig
@@ -3023,6 +3313,8 @@ to set a hotkey for adding a DOI or ISBN
alfred_bar_length
60
+ max_title_length
+ 50
version
11.1.3
diff --git a/scripts/add-new-entry.js b/scripts/add-new-entry.js
index c082cf3..d410fe0 100755
--- a/scripts/add-new-entry.js
+++ b/scripts/add-new-entry.js
@@ -129,8 +129,8 @@ function run(argv) {
const isDOI = doiRegex.test(input);
const isISBN = isbnRegex.test(input);
- const parseText = $.getenv("parseText") === "true";
- if (!isDOI && !isISBN && !parseText) return "input invalid";
+ const mode = $.getenv("mode");
+ if (!isDOI && !isISBN && mode !== "parse") return "input invalid";
// DOI
if (isDOI) {
@@ -146,7 +146,7 @@ function run(argv) {
if (!bibtexEntry.includes("@")) return "ISBN invalid";
// parse
- } else if (parseText) {
+ } else if (mode === "parse") {
// INFO anystyle can't read STDIN, so this has to be written to a file
// https://github.com/inukshuk/anystyle-cli#anystyle-help-parse
const tempPath = $.getenv("alfred_workflow_cache") + "/temp.txt";
@@ -165,7 +165,7 @@ function run(argv) {
.replace(/^ {2}/gm, "\t") // indentation
.replace(/^\s*\w+ =/gm, field => field.toLowerCase()) // lowercase all keys
.replace(keysToDeleteRegex, "")
- .replace(/^(\tpublisher.*?)\{?(?: ?\{?gmbh|ltd|publications|llc)\}?(.*)$/mi, "$1$2") // publisher garbage
+ .replace(/^(\tpublisher.*?)\{?(?: ?\{?gmbh|ltd|publications|llc ?)\}?(.*)$/im, "$1$2") // publisher garbage
.replace("\tdate =", "\tyear =") // consistently "year"
.replace("%2F", "/") // fix for URL key in some DOIs
.replace(/\tyear = \{?(\d{4}).*\}?/g, "\tyear = $1,") // clean year key
@@ -183,7 +183,15 @@ function run(argv) {
// Create keywords field
newEntryProperties.splice(1, 0, "\tkeywords = {},");
+ // Write result
const newEntry = newEntryProperties.join("\n");
appendToFile(newEntry, libraryPath);
+
+ // save title for auto-filing
+ if (mode === "id+autofile") {
+ const title = newEntry.match(/\btitle ? = .*/)[0];
+ writeToFile(title, $.getenv("alfred_workflow_cache") + "/title.txt");
+ }
+
return newCitekey; // pass for opening function
}
diff --git a/scripts/autofile-pdf.sh b/scripts/autofile-pdf.sh
index 20f2d54..169ad31 100755
--- a/scripts/autofile-pdf.sh
+++ b/scripts/autofile-pdf.sh
@@ -1,41 +1,62 @@
#!/bin/zsh
-# get selected file
+# guard clauses conditions
NO_OF_SELECTIONS=$(osascript -l JavaScript -e 'Application("Finder").selection().length')
SELECTED_FILE=$(osascript -l JavaScript -e 'decodeURI(Application("Finder").selection()[0]?.url()).slice(7)')
+# shellcheck disable=SC2154
+PDF_FOLDER="${pdf_folder/#\~/$HOME}"
+bibtex_library_path="${bibtex_library_path/#\~/$HOME}"
+citekey=$(echo "$*" | tr -d "\n")
+
+#───────────────────────────────────────────────────────────────────────────────
-# cancellation conditions
-if [[ $NO_OF_SELECTIONS -eq 0 ]] ; then
+if [[ ! -e "$PDF_FOLDER" ]]; then
+ echo "PDF folder does not exist."
+ exit 1
+fi
+if [[ -z "$PDF_FOLDER" ]]; then
+ echo "PDF folder not set."
+ exit 1
+fi
+if [[ $NO_OF_SELECTIONS -eq 0 ]]; then
echo "⛔️ No file selected."
- echo "$NO_OF_SELECTIONS"
exit 1
fi
-if [[ $NO_OF_SELECTIONS -gt 1 ]] || [[ "$SELECTED_FILE" == "multiple files" ]] ; then
+if [[ $NO_OF_SELECTIONS -gt 1 ]] || [[ "$SELECTED_FILE" == "multiple files" ]]; then
echo "⛔️ More than one file selected."
exit 1
fi
EXT="${SELECTED_FILE##*.}"
if [[ "$EXT" != "pdf" ]]; then
- echo "⛔️ Selected file not a PDF."
+ echo "⛔️ Selected file is not a PDF."
exit 1
fi
+#───────────────────────────────────────────────────────────────────────────────
+
# auto-filing
-NEW_NAME="$*.pdf"
-AUTHOR=$(echo -n "$*" | cut -d"_" -f1 | sed 's/[[:digit:]]//g') # assumes citekey is author+year
-FIRST_CHARACTER=${NEW_NAME:0:1}
-# shellcheck disable=SC2154
-PDF_FOLDER="${pdf_folder/#\~/$HOME}"
+AUTHOR=$(echo -n "$citekey" | sed -E 's/[[:digit:]]+.*//') # assumes citekey is author+year
+FIRST_CHARACTER=${citekey:0:1}
-if [[ ! -e "$PDF_FOLDER" ]] || [[ -z "$PDF_FOLDER" ]]; then
- echo "PDF folder not set or folder non-existent."
- exit 1
+# shellcheck disable=2154
+if [[ "$mode" == "id+autofile" ]]; then
+ title=$(cat "$alfred_workflow_cache/title.txt")
+else
+ title=$(grep --ignore-case --after-context=20 --max-count=1 "{${citekey}," "${bibtex_library_path}" | grep -E "\btitle ?=")
fi
+safe_truncated_title=$(
+ echo -n "$title" |
+ cut -d= -f2 |
+ tr ";:/?" "-" |
+ sed -E 's/^ *//;s/[-_ ]$//g' |
+ tr -d "{}„\"'´,#" |
+ cut -c -50
+)
AUTOFILE_FOLDER="$PDF_FOLDER/$FIRST_CHARACTER/$AUTHOR"
-AUTOFILE_PATH="$AUTOFILE_FOLDER/$NEW_NAME"
+AUTOFILE_PATH="$AUTOFILE_FOLDER/${citekey}_${safe_truncated_title}.pdf"
-if [[ -e "$AUTOFILE_FOLDER/$NEW_NAME" ]]; then
+if [[ -e "$AUTOFILE_PATH" ]]; then
echo "⛔️ There already is a pdf file."
echo "Delete it and run auto-file again."
open -R "$AUTOFILE_PATH"
@@ -43,5 +64,5 @@ if [[ -e "$AUTOFILE_FOLDER/$NEW_NAME" ]]; then
fi
mkdir -p "$AUTOFILE_FOLDER"
-mv "$SELECTED_FILE" "$AUTOFILE_PATH"
+mv "$SELECTED_FILE" "$AUTOFILE_PATH"
open -R "$AUTOFILE_PATH"
diff --git a/scripts/buffer_writer.js b/scripts/buffer_writer.js
index 9c36cab..3df58ff 100755
--- a/scripts/buffer_writer.js
+++ b/scripts/buffer_writer.js
@@ -11,7 +11,6 @@ const pdfIcon = "📕";
const litNoteFilterStr = "*";
const pdfFilterStr = "pdf";
-const maxTitleFileNameLength = 50;
const alfredBarLength = parseInt($.getenv("alfred_bar_length"));
const matchAuthorsInEtAl = $.getenv("match_authors_in_etal") === "1";
@@ -93,14 +92,6 @@ const entryArray = bibtexParse(rawBibtex) // eslint-disable-line no-undef
let shorterTitle = title;
if (title.length > alfredBarLength) shorterTitle = title.slice(0, alfredBarLength).trim() + "…";
- // autofile
- const safeTitle = title
- .slice(0, maxTitleFileNameLength)
- .replace(/[;:/\\]/g, "-")
- .replace(/[„"'´,#]/g, "")
- .replace(/[ -–]$/g, "");
- const autoFileName = `${citekey}_${safeTitle}`;
-
// URL
let urlSubtitle = "⛔️ There is no URL or DOI.";
if (url) {
@@ -221,7 +212,6 @@ const entryArray = bibtexParse(rawBibtex) // eslint-disable-line no-undef
},
quicklookurl: litNotePath,
mods: {
- fn: { arg: autoFileName },
ctrl: {
valid: url !== "",
arg: url,
diff --git a/scripts/open-entry.sh b/scripts/open-entry.sh
index 9c8c1d2..bec481d 100755
--- a/scripts/open-entry.sh
+++ b/scripts/open-entry.sh
@@ -3,7 +3,7 @@
export PATH=/usr/local/bin/:/opt/homebrew/bin/:$PATH
LIBRARY="${bibtex_library_path/#\~/$HOME}"
-CITEKEY="$*"
+CITEKEY=$(echo "$*" | tr -d "\n")
LINE_NO=$(grep -n "{$CITEKEY," "$LIBRARY" | head -n1 | cut -d':' -f1)
if [[ "$open_entries_in" == "BibDesk" ]]; then