msprev / fzf-bibtex

a BibTeX source for fzf
BSD 3-Clause "New" or "Revised" License
129 stars 15 forks source link

open pdf? #26

Closed rhaynes74 closed 2 years ago

rhaynes74 commented 2 years ago

Hi folks, is it possible to open a pdf associated with a citation? My bibtex entries all have "file= " entries. It would be great to have a way to open the pdf from within vim.

Thanks RH

msprev commented 2 years ago

Yes, this is very easy to add. However, there is no standard way of encoding linked PDF files in BibTeX files, so I did not include this kind of functionality in the original package. However, it's very easy to write something that will do it based on your own particular conventions for using 'file='.

fzf-bibtex outputs to stdout a list of bibtex keys for the items that the user has selected. All you need to do is write a short program/script (which could be in any language -- Go, Python, bash, vimscript, whatever) that takes a list of keys plus your bibtex file, finds the 'file=' fields associated with those keys and opens the named files. Because anything one does here will be bespoke to your setup (for the reason above, a general solution is not possible), you don't need to worry too much about robustness in parsing bibtex. All you need is something that works for your own bibtex files. If you want something fancy and more robust, then look at how bibtex-markdown does this. To me, that seems overkill for your case. You'll get 99% the behaviour you want just with a script/program that greps your bibtex file with regexs to find and open the named files.

rhaynes74 commented 2 years ago

Thanks for the response!

We acknowledge that the lands on which Memorial University’s campuses are situated are in the traditional territories of diverse Indigenous groups, and we acknowledge with respect the diverse histories and cultures of the Beothuk, Mi’kmaq, Innu, and Inuit of this province. On Dec 20, 2021, 1:32 PM -0330, Mark Sprevak @.***>, wrote:

Yes, this is very easy to add. However, there is no standard way of encoding linked PDF files in BibTeX files, so I did not include this kind of functionality in the original package. However, it's very easy to write something that will do it based on your own particular conventions for using 'file='. fzf-bibtex outputs to stdout a list of bibtex keys for the items that the user has selected. All you need to do is write a short program/script (which could be in any language -- Go, Python, bash, vimscript, whatever) that takes a list of keys plus your bibtex file, finds the 'file=' fields associated with those keys and opens the named files. Because anything one does here will be bespoke to your setup (for the reason above), you don't need to worry too much about robustness in parsing bibtex. If you want something fancy and robust, then look at bibtex-markdown. But that seems overkill for your case. You'll get 99% the behaviour you want just with a script/program that greps your bibtex file with regexs to find and open the named files. — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>