Skip to content

Instantly share code, notes, and snippets.

@geosharma
Last active January 13, 2024 15:36
Show Gist options
  • Save geosharma/9da7c2bcb406ef6bf78f3ffddbc6b065 to your computer and use it in GitHub Desktop.
Save geosharma/9da7c2bcb406ef6bf78f3ffddbc6b065 to your computer and use it in GitHub Desktop.
Personal notes on installing and using coBib bibliography manager

coBib - commandline bibliography management

Personal notes on creating and using coBib

References

  1. coBib PyPi
  2. coBib Documentation
  3. Introducing coBib
  4. coBib goes Textualized!

Installation

Installation using pip.

pip install cobib

I installed using pipx as I wanted it to be available globally.

pipx install cobib

Initialization

Initialized with git integration enabled.

cobib init --git

I could not find the config.py at ~/.config/cobib/ so I downloaded example.py from coBib documentaion page and copied it to the above location.

Config

To enable git in the config.py set config.database.git to True.

# coBib can integrate with `git` in order to automatically track the history of your database.
# However, by default, this option is disabled. If you want to enable it, simply change the
# following setting to `True` and initialize your database with `cobib init --git`.
# Warning: Before enabling this setting you must ensure that you have set up git properly by setting
# your name and email address.
config.database.git = True

I wanted to change the coBib download location and database location too. In the config.py file change the path in config.database.file.

# DATABASE
# These settings affect the database in general.

# You can specify the path to the database YAML file. You can use a `~` to represent your `$HOME`
# directory.
config.database.file = "~/cobib/database.yaml"

To change the download location, change the config.utils.file_downloader.default_location. path to the desired location.

# UTILS

# You can specify the default download location for associated files.
config.utils.file_downloader.default_location = "~/cobib"

Then create the folder and the file:

mkdir ~/cobib
cd cobib
touch database.yaml

The directory tree:

cobib
├── database.yaml
├── lazarte_2015.pdf
├── lazarte_2015.yaml
├── sabatini_2005.bib
└── sabatini_2005.pdf

The database.yaml was an empty file.

Adding an entry

I wanted to add an entry to the database.yaml file and associate a file to it. So, since I am a geotechnical engineer, I downloaded two reference manuals.

  1. Soil Nail Wall - Reference Manual by Lazarte et al. 2015. I did not have a bibtex file, a .bib file for the soil wall reference manual so I created a coBib .yaml file and saved it as lazarte_2015.yaml. The associated .pdf was named lazarte_2015.pdf.

The contents of the lazarte_2015.yaml file:

---
lazarte_2015:
  ENTRYTYPE: techreport
  author: C. A. Lazarte and H. Robinson and J. E. G{\'o}mez and A. Baxter and A. Cadden and R. Berg
  title: Soil Nail Walls - Reference Manual
  number: FHWA-NHI-14-007 GEC No. 7
  keywords:
  - FHWA
  - NHI
  - GEC
  year: 2015
...

The --- and the ... are maybe entry start and end indicators, the .yaml file was formatted such in the test folder.

To add this item and the associated .pdf file to database.yaml.

cobib add --yaml lazarte_2015.yaml -f lazarte_2015.pdf

The contents of the database.yaml after the above command:

---
lazarte_2015:
  ENTRYTYPE: techreport
  author: C. A. Lazarte and H. Robinson and J. E. G{\'o}mez and A. Baxter and A. Cadden
    and R. Berg
  file:
  - ~/cobib/lazarte_2015.pdf
  keywords:
  - FHWA
  - NHI
  - GEC
  number: FHWA-NHI-14-007 GEC No. 7
  title: Soil Nail Walls - Reference Manual
  year: 2015
...

Here we can see it added the file field and changed the order of the fields.

  1. Micropile Design and Construction - Reference Manual by Sabatini et al. 2005. I had a bibtex file for this one. It was generated by Zotero Better Bibtex plugin.
@techreport{sabatinietal2005,
  title = {Micropile Design and Construction Reference Manual},
  author = {Sabatini, P. J. and Tanyu, B. and Armour, T. and Groneck, P. and Keeley, J.},
  year = {2005},
  number = {FHWA NHI-05-039, NHI Course No. 132078},
  langid = {english},
  keywords = {FHWA, NHI},
  file = {sabatini_2005.pdf}
}

To add an entry for sabatini_2005 in the database.yaml and associated .pdf file to that entry:

cobib add -b sabatini_2005.bib` -f sabatini_2015.pdf

The contents of database.yaml:

---
lazarte_2015:
  ENTRYTYPE: techreport
  author: C. A. Lazarte and H. Robinson and J. E. G{\'o}mez and A. Baxter and A. Cadden
    and R. Berg
  file:
  - ~/cobib/lazarte_2015.pdf
  keywords:
  - FHWA
  - NHI
  - GEC 7
  number: FHWA-NHI-14-007 GEC No. 7
  title: Soil Nail Walls - Reference Manual
  year: 2015
...
---
sabatini_2005:
  ENTRYTYPE: techreport
  author: Sabatini, P. J. and Tanyu, B. and Armour, T. and Groneck, P. and Keeley,
    J.
  file:
  - ~/cobib/sabatini_2005.pdf
  keywords:
  - FHWA
  - NHI
  number: FHWA NHI-05-039, NHI Course No. 132078
  title: Micropile Design and Construction Reference Manual
  year: 2005
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment