gandalfsaxe Posted June 11, 2018 Share Posted June 11, 2018 Hi all, Does this exist already: An Alfred workflow that will simply autocomplete a typed word from a textfile list of special words? If not, does anyone have an idea of how to achieve this? I'm most comfortable in Python so I could probably start making this myself if somebody gave me some pointers. The use case is auto-completion of references stored in a .bib file when I write academic articles in Typora using pandoc-crossref for references, however I have to remember all references in my head since there is no autocompletion from linked .bib file. (I have asked for this before, however I was probably being too specific in my request, so now I'm making it more general just as an autocompletion system linked up to a file.) Link to comment
deanishe Posted June 11, 2018 Share Posted June 11, 2018 (edited) 5 hours ago, gandalfsaxe said: however I was probably being too specific in my request Nope, your description was excellent last time. Specific is good. For my part, at least, that's exactly why I didn't offer to help… The problem was that I thought you needed the .bib file properly parsing (i.e. it's not a simple case of "one entry per line"). Now I read it again, it looks like you might just be interested in the @article{NameYYYY, lines. Is that the case? Does every single entry begin with a single line @article{NameYYYY,? Because that's makes it pretty easy to do. If not, find me a Python or Go library that can parse the .bib file, and I'll whip something up for you. Edited June 11, 2018 by deanishe Link to comment
gandalfsaxe Posted June 11, 2018 Author Share Posted June 11, 2018 Yes precisely! I'm only interesting in a single string for each BibTeX entry, namely the crossref field, which follows from the @type{crossref, lines. The type itself can be one of 14 standard types (as I confirmed see here, here and here), where @article and @misc are the two most common types (at least for me). Is that still easy to do? PS: How do you do monospace code formatting in this forum? It's not just the grave accent `like this` as in Github Markdown. Link to comment
deanishe Posted June 11, 2018 Share Posted June 11, 2018 Could you upload a sample .bib file somewhere and post a link? Or post a URL to one. Then I'll have a look. Link to comment
gandalfsaxe Posted June 11, 2018 Author Share Posted June 11, 2018 Sure, here is a sample: https://gist.github.com/gandalfsaxe/126193c53d1f62b8e810b895bb3348bc Thanks! Link to comment
deanishe Posted June 11, 2018 Share Posted June 11, 2018 Thanks. It's late now. I'll post you something in the morning. Link to comment
deanishe Posted June 12, 2018 Share Posted June 12, 2018 (edited) Here you are. I've tried to extract the titles, too. You should be able to search on the title or the citekey, and then use ↩ to copy the citekey or ⌘↩ to copy the citekey and paste it into the active application. You have to set the path to your BibTeX file in the workflow's configuration screen (it's currently pointing at the included sample file): Edited June 12, 2018 by deanishe gandalfsaxe and giovanni 2 Link to comment
gandalfsaxe Posted June 12, 2018 Author Share Posted June 12, 2018 Thank you so much! That is exactly what I need. Much appreciated! Where can I find the actual script you made? I see a reference to `citations.py`, but where is this python script? Link to comment
vitor Posted June 12, 2018 Share Posted June 12, 2018 1 hour ago, gandalfsaxe said: Where can I find the actual script you made? I see a reference to `citations.py`, but where is this python script? Right-click the Workflow name on the list and do “Open in Finder.” gandalfsaxe 1 Link to comment
deanishe Posted June 12, 2018 Share Posted June 12, 2018 23 hours ago, gandalfsaxe said: How do you do monospace code formatting in this forum? It's not just the grave accent `like this` as in Github Markdown. Write in Markdown and then convert it to BBCode using one of @vitor's workflows: MarkdownTransform. gandalfsaxe and vitor 2 Link to comment
gandalfsaxe Posted June 14, 2018 Author Share Posted June 14, 2018 So the sample file does work for me, but I can't seem to point to another BiBTeX. I tried this: But get this: Link to comment
Tsunami Posted June 14, 2018 Share Posted June 14, 2018 As @deanishe's screenshot explains, you need a variable with the name BIBFILE. The value is the path to the file. Link to comment
gandalfsaxe Posted June 14, 2018 Author Share Posted June 14, 2018 (edited) 46 minutes ago, Tsunami said: As @deanishe's screenshot explains, you need a variable with the name BIBFILE. The value is the path to the file. Oops, missed that. Works now, thanks. Edited June 14, 2018 by gandalfsaxe Link to comment
giovanni Posted October 23, 2020 Share Posted October 23, 2020 Thank you so much @deanishe for posting this. I was looking for a way to quickly query my BibTeX database and your script is perfect. ZotHero is great too, but probably too complex for my needs. I have a quick question, though! Many of my title entries span across multiple lines (see screenshot). Would you recommend to write a script to change the BibTeX file, or is there an easy way to edit the Python script? Or, should I use a Python BibTeX parser? Thanks!! Giovanni Link to comment
deanishe Posted October 24, 2020 Share Posted October 24, 2020 9 hours ago, giovanni said: Or, should I use a Python BibTeX parser? A proper parser would make the most sense, imo. Multiline strings and backslash-escapes are way beyond the rudimentary parser in the script. giovanni 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now