If you enter a command more than twice, put it in a script.
I don't remember who said this, but it is a good rule of thumb
for administrators and essentially everybody working on a shell.
In fact, that is one of the points, why I love working with Linux.
I found myself grep'ing again and again in the same files,
so I optimized the workflow.
Both scripts are in my Scripts repository
bibgrep started as a tool just to search in my BibLaTeX files.
But as grep usually only displays the matching line (or a constant number
of surrounding lines), I ended up repeatedly opening the found position(s)
in an editor.
sed to display whole entries up to the closing
brace (that sits always on its own line in my bib files).
With some coloring, the output is better readable.
The most recent improvement is storing the identified BIB key in
the X11 clipboard (using
This allows me to directly paste it in the editor or to use
texgrep is hardly more than a one-liner,
but if no parameters are provided, it uses the X11 clipboard
as search term.
In my workflow, I use
bibgrep to find an entry (or check if it exists)
and then use
texgrep to find all places where it is cited:
$ bibgrep Kato
$ bibgrep Kato2010
The first search for "Kato" found two entries, therefore the search
was repeated with the year "Kato2010".
This is unique and a following
texgrep searches for the previously
identified key "Kato2010Airs"
and displays that this BIB entry is cited in one TEX file
(it displays also the line).
The next improvement would be to store this info and somehow direct
my vim instanct to jump to that line...