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-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
alias cit="bibtex-ls | fzf --multi --ansi | bibtex-cite -prefix='[@' -postfix=', ]' -separator='; @' | pbcopy && exit" alias citcf="bibtex-ls | fzf --multi --ansi | bibtex-cite -prefix='[Cf. @' -postfix=', ]' -separator='; @' | pbcopy && exit"
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
Cmdin 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
ito 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
Shiftwhich 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
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
go, which might be a lot of dependencies for some users. But as I said, that’s not a solution for everyone.