Disclaimer: This was created on macOS with iTerm2 and is certainly easy to replicate on Linux, but I’m not sure how to do it on Windows. It requires a certain familiarity with terminal applications and might only come in handy if you anyway always have a terminal open. So it is certainly not a solution for everyone, but some people might get some use out of it:
I’m using Obsidian to write my Master thesis. Therefore I want to enter citekeys (to be used as bibtex or biblatex references later) directly into my notes. For my references I use a plain .bib file, which I edit in vim (using snippets to add new entries). When writing text in vim, I can use fzf-bibtex to quickly fuzzy search for a citekey through my bibliography file (entering all kinds of data: (parts of) author names, titles, publishers, years etc.) and enter it into the text. I wanted to be able to do the same in Obsidian. Hopefully there will be a plugin someday, where you can just enter the path to your bibliography file and set a shortcut to open a fuzzy search window in Obsidian to enter citekeys directly. But for now I hacked together a custom solution using dropdown terminal windows.
I installed fzf-bibtex which provides the terminal commands bibtex-ls, bibtex-cite and bibtex-markdown (here only the first two are relevant). In order to set up fzf-bibtex, you can refer to the GitHub page linked above.[^1]
I created the following aliases in my .zshrc (or .bashrc):
The first one will open a fuzzy search window where I can select the entry I want, formating it correctly as [@citekey, ] and sending it to the system clipboard. The second one will do the same, but add “Cf.” at the beginning.
I created a profile for each use case in iTerm2, entering the command under the “Send at start” setting, which will execute the command automatically whenever a window of that profile is opened. Then I defined a hotkey for each profile: double-press Shift and double-press Cmd in the “Keys” section in iTerm2.
When in Obsidian, I just have to press the hotkey and a terminal window will open. I then enter my term and press enter to copy the citekey. The terminal window is closed automatically and I just paste the key into the text. (Since I use vim mode, I can press Esc and i to get the cursor to the position of the page, so I can enter it relatively effortlessly: [@citekey, 123]. Without vim mode you just have to press <-.) You can also select multiple entries at once by marking them with Shift which will give you [@citekey1; @citekey2 …].
In addition, you could use a clipboard manager to quickly access previously used citekeys. Personally, I use Maccy which allows to open it’s window via a shortcut and paste previous entrys with Cmd-1, Cmd-2 etc.
Edit: Now the terminal window closes automatically, so you don’t even have to press Cmd-w after selecting the key. This is not reflected in the gif above, but here you can see a video with the change and also an example of selecting multiple keys.
[^1]: It requires brew, fzf, bibtool and go, which might be a lot of dependencies for some users. But as I said, that’s not a solution for everyone.
That is cool. That is pretty much what I would like to have: Atom, Zettlr (and I think sublime) have plugins where you point to a bibTex file and the search window pops up when you type in ‘[@‘; you pick a reference that you need and the bibTex code gets inserted into your text.
Hey thanks for developing and sharing this! Will try it out. Currently writing my Master’s Thesis as well, and til this resolved to use Zettlr and Obsidian interchange-ably, since Zettlr supports Bibtex. Will see how it goes
Hey @phlind - this looks fantastic. I tried setting this up but keep fumbling at setting paths and getting things to work. Would you consider writing up a tutorial for total noobs unfamiliar with terminal applications and bash?
This looks amazing, thanks for sharing it. I got really excited to set it up, but I must admit, I’m stuck, I am experienced with installing these kind of stuff on manjaro linux, I’m comfortable with the terminal, dependecies fzf and all that stuff.
but this time installing things with golang really got me. fzf-bibtex works only on the terminal session when I installed it, once I close the terminal I have to install it all again. this must be my lack of experience with installing with go (I Appreciate any links to relevant documentation)
I’m also having trouble with this set up of the cache and .bib file, I got my references.bib file but it’s not reading it when I follow the following format.
bibtex-ls [-cache=...] [file1.bib file2.bib ...]
This set up looks great, I’ve been trying to install things for hours, I’ll have to second @pb21 , of course there’s a lot of moving parts in this set up, so a comprehensive tutorial on everything would be a lot to ask, since a lot of the basics are easily googlable and dependant on onces set up.
For me, it would just be some pointers on how to set up fzf-bibtex considering that all dependancies are installed, and setting that up with cache and .bib file
@santi@pb21 Yes, I understand that there are a lot of dependencies, which are not that easy to set up. In my case, I already had those working when I started using Obsidian. I will try to explain the process of setting it up in more detail, but I also have to dive into the details again first. I hope I have time to do this during the next days or the weekend!
Atom Hack (kind of): it just occurred to me that it might be much easier just to keep Atom open and search for citekeys through it (make sure to install plugin autocomplete-bibtex) and point to your bibtex file in the settings of your plugin. Find you key and copy-paste it to Obsidian.
thank you @phlind we really appreciate your efforts, it would mean a lot.
thanks for the tip @romanov.maxim I currently do the same with zettlr, and I’ll try it in atom.
I still think it’s a lot more valuable to be able to do it from the terminal, since it’s a lot more light weight and fast, that way I don’t need to keep another app open (or launch it every time), but it’s definetly a more user friendly approach thanks
I think, since this new great plugin exists now, it’s not necessary anymore to give a detailed tutorial. The plugin does exactly the same thing and even more, but in a more elegant way, since it’s integrated into Obsidian.
To be honest, I think the new community is great specially for beginners, but still being able to have a lot of control with this method is still a superior alternative. I don’t think the community plugin replaces this yet!