You are not logged in.
This is an insanely simple project, but I've found it handy so I thought I'd post it.
Lobster-bib
A CLI frontend to the btparse bibtex database parser
Usage
lobster-bib <file.bib> [ -o ] [ <search-strings> ] [ : <output-types> ]
file.bib: required and must be a bibtex database
-o: use "or" search rather than "and" search
search-strings: any number of strings to match against any entry field, or key=value pairs to match against a specific field. Multi-word strings must be quoted
output-types: select the fields to display in the output, by default all fields are printed
Suggested use
For convenient use add an alias to your shell rc file with a name of your choice and specifying your reference database
alias bib='lobster-bib ~/refdb.bib'
Get it here. There is a PKGBUILD provided there, but I don't know if 66 lines of simple code is worth adding an AUR package. I'll let user-interest dictate that.
This does depend on btparse which is available in the AUR (understatement really, btparse does all the cool stuff).
Examples: (assuming the above alias)
Get the title of all articles related to latex: `bib latex : title`
Get the title of all articles by Knuth related to latex: `bib author=knuth latex : title`
Get all info on any article by Knuth with latex in the title `bib author=knuth title=latex`
Get the year and author of publication on any article by Knuth or with latex in the title: `bib -o author=knuth title=latex : year author`
Last edited by Trilby (2013-09-18 01:36:12)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
This sounds nice. Can it cope with biblatex?
EDIT: Also, is there a way to get it to print the entry key?
EDIT2: Also also, can you feed it multiple bib databases and can it cope with abbreviations?
Last edited by cfr (2013-09-17 23:18:07)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
I like the New England slant to the name I'll try it out when I get home tonight.
I was in your state a couple weeks back. I'll be back next month; I expect it will be a bit more fall like by then.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
CFR, I'm planning to add the entry key as well. This was just thrown together as a bit of a proof-of-concept, and I was surprised how nicely btparse works.
I'm not sure (yet) of the differences between biblatex and bibtex. I was under the - perhaps naive - impression that they were just different programs used to typset citations from the same type of database. I'll look into that though, the short answer is that there is very little to my code: if the btparse library (not mine) handles biblatex, then so will lobster-bib, if not, then not.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
It seems btparse is not available for x86_64?
EDIT: It sounds nice otherwise. Even if it doesn't do everything . Given that right now I just use grep...
biblatex works with bibtex files but before long your database files end up not being suitable for bibtex. However, unless it ignores undefined entry types, I'd think it would work with biblatex .bib files even if it isn't designed to. It might not work perfectly but it should work for at least basic stuff such as title and author.
However, the architecture thing is a bit more of an obstacle for me, I'm afraid!
Last edited by cfr (2013-09-17 23:26:45)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
I'm on x86_64 and it works fine. I did edit the PKGBUILD to put "any" in the arch field, I don't know why it has i686 only. I also fixed the PKGBUILD to have a package function.
Ah, it's orphaned ... how cute, it needs a new home. Standby, adoption paperwork under way.
EDIT: adopted, fixed, builds on x86_64.
Last edited by Trilby (2013-09-17 23:42:20)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Wow - that was quick. Thanks - off to have another go now.
I was in the middle of trying to figure out whether the cpan module
BibTeX::Parser (GERHARD/BibTeX-Parser-0.65.tar.gz)
was the same thing and, if so, wondering what on Earth is the "right" way to install cpan modules on Arch... .
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
EDIT: Ignore this post. It was complaining it can't find pod2man and I was confused because I couldn't find a package. But ignore me. This won't happen to anybody else (well - not unless they've done just what I've done, which isn't likely).
EDIT2: Yep, builds fine now - thanks very much.
EDIT3: Unfortunately, it does not work at all for me. However, this is almost certainly because of the way I manage my .bib files and nothing to do with your software. Shame, though - guess it is back to grep!
In case anybody is curious about how I get this not to work, I have the following set up:
* abbrv.bib: miscellaneous abbreviations including stuff like "and"
* authors.bib: list of all authors and editors defined to abbreviations as strings e.g. @string{eliot-ts = {Eliot, T. S.}}
* journals-series.bib: similar for journal and series titles
* similarly for places, publishers etc.
* bunch of topic-related .bib files with the actual database entries which use the abbreviations in the previous files
This ensures that I don't introduce different versions of author names or journal titles inadvertently but unfortunately also seems to break lobster-bib (or more likely btparse).
Last edited by cfr (2013-09-18 00:04:26)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
Actually there is a way to deal with that - I'll add it soon: btparse can read a series of files just like that - I just have to provide the mechanism to do so.
At the very worst and ugliest, you could use the following for now:
alias bib='cat abbrv.bib authors.bib journals.bib publishers.bib topic1.bib topic2.bib > /tmp/lobster.bib && lobster-bib /tmp/lobsterbib'
But I should be able to add reading a list of files to lobster-bib itself by this weekend.
EDIT: actually, don't you have some overall bib file that includes each of those? btparse should follow include links properly (I think). EDIT2: maybe I'm talking outa' my ***, I know tex files can include other tex files, I guess I don't know about bib(la)tex.
EDIT: a better alias, which actually makes me think I shouldn't bother revising the code:
alias bib='cat abbrv.bib authors.bib journals.bib ... | lobster-bib -'
The "-" reads the bib file from stdin, and the cat concatenates all the files and pipes them to the stdin. The dots there are, of course, to be filled in by the files which should be specified with paths.
Last edited by Trilby (2013-09-18 00:36:00)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks. I'll give that a whirl and/or look forward to coming features.
You know, that's an interesting question (about inclusion). It really never occurred to me to try it for .bib files. I've no idea if it would work... hmm... would be rather handy, though, if it does...
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
I just tested with some simple bib files partition into string macro definitions, and entries in various files. The cat invocation above works here.
Given that, I don't think there is reason to add a bunch of code to open, read, and parse files, including a config file; just pass all the files to stdin. An alias or shell function would make this much more practical.
Cfr, have you tried that yet?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I just tested with some simple bib files partition into string macro definitions, and entries in various files. The cat invocation above works here.
Given that, I don't think there is reason to add a bunch of code to open, read, and parse files, including a config file; just pass all the files to stdin. An alias or shell function would make this much more practical.
Cfr, have you tried that yet?
Yes, unfortunately I get
sym: string table overflow (4096 chars)
EDIT: I haven't yet had a chance to look into the possibility of including bib files in a meta-bib file, though, I'm afraid. I'm not actually sure where to look for this but it does seem like the sort of thing which might be possible.
Last edited by cfr (2013-09-21 02:31:28)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline