Skip to content

Instantly share code, notes, and snippets.

@geosharma
Last active January 13, 2024 15:36
Show Gist options
  • Select an option

  • Save geosharma/9da7c2bcb406ef6bf78f3ffddbc6b065 to your computer and use it in GitHub Desktop.

Select an option

Save geosharma/9da7c2bcb406ef6bf78f3ffddbc6b065 to your computer and use it in GitHub Desktop.

Revisions

  1. geosharma revised this gist Jan 13, 2024. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion cobib.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,9 @@ Installation using `pip`.

    ```pip install cobib```

    I installed from the `AUR`.
    I installed using `pipx` as I wanted it to be available globally.

    ```pipx install cobib```

    ## Initialization
    Initialized with `git` integration enabled.
  2. geosharma revised this gist Jan 13, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions cobib.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,8 @@ Installation using `pip`.

    ```pip install cobib```

    I installed from the `AUR`.

    ## Initialization
    Initialized with `git` integration enabled.

  3. geosharma revised this gist Jan 13, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cobib.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # coBib - commandline bibliography management
    Personal notes on creating and using coBib

    ## References
    1. [coBib PyPi](https://pypi.org/project/cobib/)
  4. geosharma created this gist Jan 13, 2024.
    174 changes: 174 additions & 0 deletions cobib.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,174 @@
    # coBib - commandline bibliography management

    ## References
    1. [coBib PyPi](https://pypi.org/project/cobib/)
    2. [coBib Documentation](https://mrossinek.gitlab.io/cobib/cobib.html)
    3. [Introducing coBib](https://mrossinek.gitlab.io/programming/introducing-cobib/)
    4. [coBib goes Textualized!](https://mrossinek.gitlab.io/programming/cobib-goes-textualized/)

    ## Installation
    Installation using `pip`.

    ```pip 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](https://mrossinek.gitlab.io/cobib/cobib.html#configuration) 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.

    2. 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
    ...
    ```