diff --git a/README.md b/README.md
index 762bd71..e16aea6 100644
--- a/README.md
+++ b/README.md
@@ -10,13 +10,13 @@ A citation picker and minimalistic reference manager for [Alfred](https://www.al
## Feature Overview
- Inserts __Pandoc Citation Syntax__ (`[@citekey]`), supporting page numbers & multiple citations (`[@citekey, p. 23; @citekey, p. 42]`). Can also be configured to use __LaTeX__, __Multi-Markdown__, __eta templates__, __Org Mode__, `[[wikilinks]]`, or `#tags` or `bare citkeys` as citation format.
-- __app-independent:__ works system-wide, in every text field of every app.
-- __Smart Search:__ search for citekeys, authors, title, publication, keywords (tags), include or exclude authors in *et al*, tab-completion, fuzzy-matching, sorting recently used entries to the top.
+- __App-independent:__ works system-wide, in every text field of every app.
+- __Smart Search:__ search for citekeys, authors, title, publication, keywords (tags), include or exclude authors in *et al.*, tab-completion, fuzzy-matching, sorting recently used entries to the top.
- __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 required plugins, no setup. Just enter the path to your `.bib` file.
- __Minimalistic reference manager__: add or remove entries to 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.
+- __Obsidian integration:__ When located in your [Obsidian Vault](https://obsidian.md/), literature notes are automatically opened or created in Obsidian instead of the default markdown app.
## Table of Contents
@@ -28,7 +28,7 @@ A citation picker and minimalistic reference manager for [Alfred](https://www.al
- [Icon Meanings](#icon-meanings)
- [Changing the Citation Format](#changing-the-citation-format)
- [Available Formats](#available-formats)
- - [Further Format Customization](#further-format-customization)
+ - [Other Format Customization](#other-format-customizations)
- [Advanced Usage](#advanced-usage)
- [Bibliography Actions](#bibliography-actions)
- [Literature Note Actions](#literature-note-actions)
@@ -49,17 +49,17 @@ A citation picker and minimalistic reference manager for [Alfred](https://www.al
Press the hotkey in any text field to start the citation picker.
### Search
-- Search for the title, author/editor (last name), year, or collection or journal-title.
+- You can search for the title, author/editor (last name), year, or collection or journal-title.
- Prepend `@` to a word to search for a citekey, for example `@Grieser2020`.
- Prepend `#` to search for keywords (tags), for example `#sociology`.
-- *Smart Queries*: You can search for any combination of the above. For example, the query `2020 #cognition Grieser` searches for entries published in 2020, with the tag "cognition," and with "Grieser" as author/editor.
+- *Smart Queries*: You can search for any combination of the above. For example, the query `2020 #cognition grieser` searches for entries published in 2020, with the tag "cognition," and with "Grieser" as author/editor.
### Citation Actions
- `↵`: Paste the citekey of the selected citation.
- `⌥ + ↵`: Add another citation.
- `⌘⇧ + ↵`: Paste an inline-citation (citation without surrounding formatting, for example `@Grieser2022` instead of `[@Grieser2022]`)
- `⌘ + ↵`: Add page numbers before pasting the selected citekey.
- - Confirm the page number with `⌥ + ↵` to add another citation afterwards.
+ - Confirm the page number with `⌥ + ↵` to add another citation afterward.
- Confirm with `⌘⇧ + ↵` for an inline-citation with page number (`@Grieser2022 [p. 42]`).
### URL Actions
@@ -82,35 +82,36 @@ Press the hotkey in any text field to start the citation picker.
### Available Formats
You can use the `scp` and select __Change Citation Format__ to change the format of the citations:
-- Pandoc (default)
+- pandoc (default)
- Org Mode
- Multi-Markdown (MMD)
-- Latex
-- Eta template
+- LaTeX
+- eta
- iA Writer
-- Wikilink
+- wikilink
- Tag
-- Bare Citekey
-- Bracketed Citekey
+- bare citekey
+- bracketed citekey
> __Note__
> Not all formats support all citation-related features. For example, adding Page numbers as well as inline-citations are not supported for Latex, Wikilinks, and Tags, and iA Writer does not support multiple citations.
-### Further Format Customization
+### Other Format Customizations
If you want to use a format that is not available, you can customize the format yourself by changing the workflow environment variables starting with `_format`. (Tutorial: [how to set environment variables in Alfred](https://www.alfredapp.com/help/workflows/advanced/variables/#environment))
-If there is a citation syntax that is commonly used, or if you want to improve support for an existing format, feel free to make a PR to [this file which generates the formats](https://github.com/chrisgrieser/alfred-bibtex-citation-picker/blob/main/scripts/toggle-citation-format.js) or open a [Feature Request](https://github.com/chrisgrieser/alfred-bibtex-citation-picker/issues/new?assignees=&labels=enhancement&template=feature_request.yml&title=Feature+Request%3A+).
+If there is a citation syntax that is commonly used, or if you want to improve support for an existing format, feel free to open a [Feature Request](https://github.com/chrisgrieser/alfred-bibtex-citation-picker/issues/new?assignees=&labels=enhancement&template=feature_request.yml&title=Feature+Request%3A+).
+You can also make a PR to [this file which defines the citation formats](https://github.com/chrisgrieser/alfred-bibtex-citation-picker/blob/main/scripts/toggle-citation-format.js).
## Advanced Usage
### 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.
- `⌘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`: 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. Afterwards, the entry is opened.
+ - 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__
@@ -120,9 +121,9 @@ If there is a citation syntax that is commonly used, or if you want to improve s
- The citation picker looks in the folder specified in the workflow settings for files that are *exactly* named like the citekey, optionally followed by an underscore and some text like `{citekey}_{title}.md`. The citekey must not contain underscores (`_`), the filename should not include the `@`.
- Entries that have such a literature note is indicated by a `📓`.
- `⌃⌥ + ↵`[^2]: Open the literature note.
- - If the file is in an [Obsidian Vault](https://obsidian.md/), it is opened directly in Obsidian instead of the default text editor.
+ - If the file is in your [Obsidian Vault](https://obsidian.md/), it is opened directly in Obsidian instead of the default text editor.
- If there is no literature note, a new one is created.
-- `⌘ + Y`: Preview the literature note with QuickLook (requires QLmarkdown or Peek[^1]).
+- `⌘ + Y`: Preview the literature note with `QuickLook` (requires `QLmarkdown` or `Peek`[^1]).
- Add `*` to any search query to filter only for entries with literature notes, for example `* grieser` searches for entries matching "grieser" which also have a literature notes. Can be combined with other queries (see: [smart queries](#search)).
### PDF Management Actions
@@ -131,17 +132,18 @@ The following features require that all your PDFs are located in the folder spec
- `fn + ↵`: __Auto-file and auto-rename__ the *currently selected PDF*. Inside your selected PDF folder, uses the template path: `{first_letter_of_citekey}/{citekey-author-part}/{citekey}_{shortened_title}.pdf`
- The `📕` indicates that the entry already has an associated PDF at that location.
- `Hyper + ↵`[^2]: If the entry has an associated PDF file, open it with the default PDF reader. The citekey must not contain an underscore (`_`).
-- ℹ️ Add `pdf` to any search query to filter only for entries with PDFs that have been added by the auto-file feature. `pdf grieser`, for example, displays only entries from the author "Grieser" with PDFs. Can be combined with other queries (see: [smart queries](#search)).
+- Add `pdf` to any search query to filter only for entries with PDFs that have been added by the auto-file feature. `pdf grieser`, for example, displays only entries from the author "Grieser" with PDFs. Can be combined with other queries (see: [smart queries](#search)).
### Auxiliary Features
+
Triggered via the Alfred Keyword `scp` (for `S`upercharged `C`itation `P`icker).
-
-- __Cheat sheet: Citation Picker Actions__: Open a cheat sheet of the available actions of the Supercharged Citation Picker.
+
+- __Cheatsheet: Citation Picker Actions__: Open a cheat sheet of the available actions of the Supercharged Citation Picker.
- __Citation Style Search__: Search for a citation style (`.csl` file), which is downloaded to the location specified in your workflow settings (default: `~/.pandoc/csl/`).
- __Force Buffer Reload__: Force a reload of the citation picker. Mostly for debugging purposes.
-
## About the Developer
+
In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch.
### Profiles
@@ -159,9 +161,8 @@ In my day job, I am a sociologist studying the social mechanisms underlying the
### Credits
Icons created by Freepik (Flaticon)
-
-[^1]: [QLmarkdown](https://github.com/sbarex/QLMarkdown) and [Peek](https://apps.apple.com/app/peek-quick-look-extension/id1554235898) both enable previewing of Markdown documents. Peek works with a wide range of other file types than Markdown, but costs around 5€. QLMarkdown is free, but only works for Markdown and requires some minor setup. To enable the proper display of YAML headers, you need to enable the respective setting in the Advanced Options of QLMarkdown or Peek.
+[^1]: [QLmarkdown](https://github.com/sbarex/QLMarkdown) and [Peek](https://apps.apple.com/app/peek-quick-look-extension/id1554235898) both enable previewing of Markdown documents. Peek works with a wide range of other file types than Markdown, but costs around 5€. `QLMarkdown` is free, but only works for Markdown and requires some minor setup. To enable the proper display of YAML headers, you need to enable the respective setting in the Advanced Options of `QLMarkdown` or Peek.
[^2]: `Hyper` is an artificial "fifth" modifier key equal to `⌘⌥⌃⇧`, and can be created using apps like [Karabiner Elements](https://karabiner-elements.pqrs.org/), [BetterTouchTool](https://www.macupdate.com/app/mac/32953/bettertouchtool), or [Hyperkey](https://hyperkey.app/).
diff --git a/info.plist b/info.plist
index a2e11c2..41ba587 100644
--- a/info.plist
+++ b/info.plist
@@ -120,6 +120,19 @@
+ 15177777-C902-4390-9D4A-0C06D8309493
+
+
+ destinationuid
+ F46030BA-A511-425D-99AB-40C220A6F0F3
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
1C0964D1-AA81-478A-B406-28E96DDD9E82
@@ -269,13 +282,23 @@
destinationuid
- 85B36033-B322-42EB-AE72-6A7EA59B184B
+ 2DC90122-FC40-44CA-8F59-E3C16AC99651
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
+ destinationuid
+ 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
modifiers
0
modifiersubtext
sourceoutputuid
- 14FB4C6A-E89A-4DBE-8F36-87C64E7B4314
+ DC91ADC0-DB87-468A-9BCF-48A5482F190F
vitoclose
@@ -286,6 +309,8 @@
0
modifiersubtext
+ sourceoutputuid
+ 14FB4C6A-E89A-4DBE-8F36-87C64E7B4314
vitoclose
@@ -449,19 +474,6 @@
- 85B36033-B322-42EB-AE72-6A7EA59B184B
-
-
- destinationuid
- 2DC90122-FC40-44CA-8F59-E3C16AC99651
- modifiers
- 0
- modifiersubtext
-
- vitoclose
-
-
-
8B51C1A0-EAD2-457B-A532-6CC16C7F015E
@@ -589,7 +601,7 @@
destinationuid
- F46030BA-A511-425D-99AB-40C220A6F0F3
+ 15177777-C902-4390-9D4A-0C06D8309493
modifiers
0
modifiersubtext
@@ -1454,42 +1466,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
-
- argument
- {var:_format_citekey_prefix}{query}{var:_format_citekey_suffix}
- passthroughargument
-
- variables
-
-
- type
- alfred.workflow.utility.argument
- uid
- A1A6DEC2-1AF1-4110-9DA9-01400A1902FF
- version
- 1
-
config
@@ -1516,23 +1492,21 @@ JSON.stringify({ 'items': entry_array });
config
- acceptsfiles
-
- acceptsmulti
- 0
- acceptstext
-
- acceptsurls
+ autopaste
- name
- Parse Bibliography Entry
+ clipboardtext
+ {query}
+ ignoredynamicplaceholders
+
+ transient
+
type
- alfred.workflow.trigger.universalaction
+ alfred.workflow.output.clipboard
uid
- 5EF575B0-D940-4403-BE95-B5580A538B18
+ 83A9C045-9885-4C76-B88D-DAC01E9528C0
version
- 1
+ 3
config
@@ -1566,6 +1540,44 @@ JSON.stringify({ 'items': entry_array });
version
1
+
+ config
+
+ argument
+ {var:_format_citekey_prefix}{query}{var:_format_citekey_suffix}
+ passthroughargument
+
+ variables
+
+
+ type
+ alfred.workflow.utility.argument
+ uid
+ A1A6DEC2-1AF1-4110-9DA9-01400A1902FF
+ version
+ 1
+
+
+ config
+
+ acceptsfiles
+
+ acceptsmulti
+ 0
+ acceptstext
+
+ acceptsurls
+
+ name
+ Parse Bibliography Entry
+
+ type
+ alfred.workflow.trigger.universalaction
+ uid
+ 5EF575B0-D940-4403-BE95-B5580A538B18
+ version
+ 1
+
config
@@ -1586,6 +1598,27 @@ JSON.stringify({ 'items': entry_array });
version
1
+
+ config
+
+ lastpathcomponent
+
+ onlyshowifquerypopulated
+
+ removeextension
+
+ text
+
+ title
+ ⚠️ {query}
+
+ type
+ alfred.workflow.output.notification
+ uid
+ 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
+ version
+ 1
+
config
@@ -1616,28 +1649,6 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
version
2
-
- config
-
- argument
- {query}
- passthroughargument
-
- variables
-
- mode
- id+autofile
- pdf_filepath
- {query}
-
-
- type
- alfred.workflow.utility.argument
- uid
- 85B36033-B322-42EB-AE72-6A7EA59B184B
- version
- 1
-
config
@@ -1661,25 +1672,6 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
version
2
-
- config
-
- acceptsmulti
- 0
- filetypes
-
- com.adobe.pdf
-
- name
- Add Entry & Autofile
-
- type
- alfred.workflow.trigger.action
- uid
- B2C01CFD-4663-47E1-9D0E-8061943CDBC5
- version
- 1
-
config
@@ -1698,21 +1690,19 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
config
- lastpathcomponent
-
- onlyshowifquerypopulated
-
- removeextension
-
- text
-
- title
- ⚠️ {query}
+ acceptsmulti
+ 0
+ filetypes
+
+ com.adobe.pdf
+
+ name
+ Add Entry & Autofile
type
- alfred.workflow.output.notification
+ alfred.workflow.trigger.action
uid
- 9C01A8C9-CBF3-4261-A0F2-CD6DC0E55515
+ B2C01CFD-4663-47E1-9D0E-8061943CDBC5
version
1
@@ -1727,17 +1717,31 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
matchcasesensitive
matchmode
- 1
+ 0
matchstring
No DOI found in first 4 pages.
outputlabel
- found
+ no DOI
uid
14FB4C6A-E89A-4DBE-8F36-87C64E7B4314
+
+ inputstring
+
+ matchcasesensitive
+
+ matchmode
+ 0
+ matchstring
+ pdfgrep not installed.
+ outputlabel
+ no pdfgrep
+ uid
+ DC91ADC0-DB87-468A-9BCF-48A5482F190F
+
elselabel
- not found
+ DOI found
hideelse
@@ -1807,6 +1811,28 @@ echo -n $dummyBib | pandoc --citeproc --read=markdown --write=plain --csl $csl -
version
1
+
+ config
+
+ argument
+ {query}
+ passthroughargument
+
+ variables
+
+ mode
+ id+autofile
+ pdf_filepath
+ {query}
+
+
+ type
+ alfred.workflow.utility.argument
+ uid
+ 15177777-C902-4390-9D4A-0C06D8309493
+ version
+ 1
+
type
alfred.workflow.utility.junction
@@ -2605,7 +2631,7 @@ In some cases, you may need to restart Alfred for this change to take effect.
colorindex
9
xpos
- 180
+ 260
ypos
950
@@ -2660,6 +2686,15 @@ In some cases, you may need to restart Alfred for this change to take effect.
ypos
1590
+ 15177777-C902-4390-9D4A-0C06D8309493
+
+ colorindex
+ 9
+ xpos
+ 195
+ ypos
+ 845
+
1B72EC4E-33E7-4144-B43B-3037510ADA3A
colorindex
@@ -2696,9 +2731,9 @@ In some cases, you may need to restart Alfred for this change to take effect.
colorindex
1
xpos
- 620
+ 590
ypos
- 830
+ 815
2A483E3B-2BAB-408A-9759-4C0F65D760CF
@@ -2725,9 +2760,9 @@ In some cases, you may need to restart Alfred for this change to take effect.
note
create new entry
xpos
- 325
+ 425
ypos
- 555
+ 480
30006A6B-EAF9-4531-8694-5E878A0FB80E
@@ -2822,9 +2857,9 @@ to set a hotkey for adding DOI/ISBN
note
DOI
xpos
- 325
+ 415
ypos
- 835
+ 820
4DA0A4D6-F21E-433C-9EB1-C781B01CA932
@@ -2973,15 +3008,6 @@ to set a hotkey for adding DOI/ISBN
ypos
485
- 85B36033-B322-42EB-AE72-6A7EA59B184B
-
- colorindex
- 9
- xpos
- 235
- ypos
- 690
-
8B51C1A0-EAD2-457B-A532-6CC16C7F015E
colorindex
@@ -3045,9 +3071,9 @@ to set a hotkey for adding DOI/ISBN
colorindex
1
xpos
- 480
+ 595
ypos
- 830
+ 675
A1A6DEC2-1AF1-4110-9DA9-01400A1902FF
@@ -3116,9 +3142,9 @@ to set a hotkey for adding DOI/ISBN
colorindex
9
xpos
- 465
+ 565
ypos
- 575
+ 500
C64ACAF0-66C8-48A8-A3C4-B55C7E282697
@@ -3182,7 +3208,7 @@ to set a hotkey for adding DOI/ISBN
note
get doi from PDF
xpos
- 180
+ 260
ypos
815
@@ -3416,7 +3442,7 @@ to set a hotkey for adding DOI/ISBN
50
version
- 11.4.0
+ 11.3.0
webaddress
https://github.com/chrisgrieser/alfred-bibtex-citation-picker
diff --git a/scripts/add-new-entry.js b/scripts/add-new-entry.js
index b84d681..0841c89 100755
--- a/scripts/add-new-entry.js
+++ b/scripts/add-new-entry.js
@@ -27,11 +27,12 @@ function readFile(path) {
/**
* @param {string} text
- * @param {string} file
+ * @param {string} filepath
*/
-function writeToFile(text, file) {
+function writeToFile(text, filepath) {
+ app.doShellScript(`mkdir -p "$(dirname "${filepath}")"`);
const str = $.NSString.alloc.initWithUTF8String(text);
- str.writeToFileAtomicallyEncodingError(file, true, $.NSUTF8StringEncoding, null);
+ str.writeToFileAtomicallyEncodingError(filepath, true, $.NSUTF8StringEncoding, null);
}
//──────────────────────────────────────────────────────────────────────────────
@@ -193,12 +194,6 @@ function run(argv) {
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");
- }
-
delay(0.1); // delay to ensure the file is written
return newCitekey; // pass for opening function
}
diff --git a/scripts/autofile-pdf.sh b/scripts/autofile-pdf.sh
index 7313e08..d1568f0 100755
--- a/scripts/autofile-pdf.sh
+++ b/scripts/autofile-pdf.sh
@@ -4,22 +4,31 @@ bibtex_library_path="${bibtex_library_path/#\~/$HOME}"
citekey=$(echo "$*" | tr -d "\n")
#───────────────────────────────────────────────────────────────────────────────
+# GET FILEPATH & CHECK VALIDITY OF VARIABLES
# shellcheck disable=2154
-if [[ "$mode" == "if+autofile" ]]; then
+PDF_FOLDER="${pdf_folder/#\~/$HOME}"
+if [[ ! -e "$PDF_FOLDER" ]]; then
+ echo "PDF folder does not exist." && return 1
+elif [[ -z "$PDF_FOLDER" ]]; then
+ echo "PDF folder not set." && return 1
+fi
+
+# shellcheck disable=2154
+if [[ "$mode" == "id+autofile" ]]; then
SELECTED_FILE="$pdf_filepath" # set via Alfred
else
- # guard clauses conditions
- PDF_FOLDER="${pdf_folder/#\~/$HOME}"
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)')
EXT="${SELECTED_FILE##*.}"
- 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." && exit 1; fi
- if [[ $NO_OF_SELECTIONS -gt 1 ]]; then echo "⛔️ More than one file selected." && exit 1; fi
- if [[ "$EXT" != "pdf" ]]; then echo "⛔️ Selected file is not a PDF." && exit 1; fi
+ if [[ $NO_OF_SELECTIONS -eq 0 ]]; then
+ echo "⛔️ No file selected." && return 1
+ elif [[ $NO_OF_SELECTIONS -gt 1 ]]; then
+ echo "⛔️ More than one file selected." && return 1
+ elif [[ "$EXT" != "pdf" ]]; then
+ echo "⛔️ Selected file is not a PDF." && return 1
+ fi
fi
#───────────────────────────────────────────────────────────────────────────────
@@ -29,11 +38,7 @@ AUTHOR=$(echo -n "$citekey" | sed -E 's/[[:digit:]]+.*//') # assumes citekey is
FIRST_CHARACTER=${citekey:0: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
+title=$(grep --ignore-case --after-context=20 --max-count=1 "{${citekey}," "${bibtex_library_path}" | grep -E "\btitle ?=")
safe_truncated_title=$(
echo -n "$title" |
cut -d= -f2 |
@@ -51,7 +56,7 @@ if [[ -e "$AUTOFILE_PATH" ]]; then
echo "⛔️ There already is a pdf file."
echo "Delete it and run auto-file again."
open -R "$AUTOFILE_PATH"
- exit 1
+ return 1
fi
mkdir -p "$AUTOFILE_FOLDER"
diff --git a/scripts/get-doi-from-pdf.sh b/scripts/get-doi-from-pdf.sh
index 1227d72..ddc9807 100755
--- a/scripts/get-doi-from-pdf.sh
+++ b/scripts/get-doi-from-pdf.sh
@@ -1,7 +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
+if ! command -v pdfgrep &>/dev/null; then echo -n "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."