Skip to main content

Pramaana

The great thing about Zotero is its actively-maintained translation server (i.e. which parses a webpage and gets its metadata to generate a bib file). The thing I don't like is its client. Ideally you want references to be sorted into nested folders, along with corresponding pdfs etc. -- then you can just move them around or edit them however, in your terminal, file manager whatever without doing tons of point-and-click operations in Zotero client.

pramaana is a minimalist command-line reference manager that works with BibTeX files and the Zotero translation server. Basically works like Zotero with BetterBibTeX plus Zotmoov (or the earlier Zotfile).

In theory this is the perfect and optimal reference manager. Unfortunately it turns out the published Zotero Translation Server module doesn't work as well as what Zotero actually uses. Hopefully that's one day fixed, and then this will really be great.

Installation

The recommended way to install Pramaana is using pipx:

pipx install pramaana
pramaana-install-completions # to install shell completions; see below though

This will install Pramaana in an isolated environment while making the pramaana command available globally.

Prerequisites

Pramaana requires the Zotero translation server to be running for URL-based reference imports. You can start it using Docker:

docker pull zotero/translation-server
docker run -d -p 1969:1969 --rm --name translation-server zotero/translation-server

Usage

Main commands:

# Create a new reference
# 1) Omit `--from` to write in a bib file manually in vim, with a pre-
#    specified template given by --template=article, book, web etc.
#    (can be configured, see later)
# 2) Use `--attach` without any arguments (i.e. omit `paper.pdf`) to 
#    attach the latest item in `~/Downloads`
#    (can be configured, see later).
# 3) Use `--attach 3` (or any positive integer) to attach the latest 3
#    items in `~/Downloads`
pramaana new cs/ai_books/sutton_barto --from https://books.google.com/books?id=GDvW4MNMQ2wC --attach paper.pdf
pramaana new cs/ai_books/sutton_barto --template=book --attach paper.pdf
pramaana new cs/ai_books/sutton_barto --attach
pramaana new cs/ai_books/sutton_barto --attach 3

# Update a reference:
pramaana edit cs/ai_books/sutton_barto --from https://books.google.com/books?id=GDvW4MNMQ2wC --attach paper.pdf

# Run all configured exports (omit arguments to run all exports, see configuration below):
# pramana export is called automatically after any pramana new, edit, rm, trash, mv or cp operations
# but if you change anything outside the pramana command line, you'll want to run it afterward
pramaana export id1 id2

# Find reference
pramaana find "sutton" -type f

# Search for text
pramaana grep "sutton" cs/ # supports all grep options, but must be given at end
pramaana grep "sutton" cs/ --include="*.bib" # to only search .bib files (rather than e.g. pdf)

# Import from Zotero:
# NOTE: see below for how to export your Zotero library in a way that can be imported into Pramana
pramaana import /path/to/special_bbt_export.bib

# Cleanup operations
# For now this just does:
# 1) change all citation keys to match name of folder containing bib file
# --recursive/-r should usually be turned on, unless you want to rename just one reference
# --dry-run to just show what changes would be made
pramaana clean cs/ -r --dry-run

Basic commands (all of these support the basic options supported by the commands they wrap, e.g. rm -rf, but the options need to be added at the end):

pramaana ls # or pramaana ls /path/to/subdir
pramaana rm path/to/subdir
pramaana trash path/to/subdir # if trash-cli is installed
pramaana mv path1 path2
pramaana cp path1 path2
pramaana ln path1 path2 -s
pramaana show cs/ai_books/sutton_barto/ # shows bibliographic content; add `-r` option to concatenate all recursively
pramaana open /path/to/file/or/subdir # opens file or directory in default application; omit arguments to just open the `pramaana_path` folder
pramaana abs path/to/file/or/subdir # appends relative path within pramaana to `pramaana_path`
pramaana rel /path/to/file/or/subdir # relativizes a full path to `pramaana_path`

Configuration

Pramaana stores its configuration in ~/.pramaana/config.json. The default configuration can be customized:

{
    "storage_format": "bib",  # only bib is supported for now
    "attachment_mode": "cp",  # cp, mv, or ln
    "attachment_watch_dir": "~/Downloads",
    "pramaana_path": "~/.pramaana_data",  # default location for references
    "translation_server": "http://localhost:1969",  
    "exports": {
        "everything": { # give an ID for each export
            "source": ["/.exports/*"],
            "destination": "~/.pramaana_data/.exports/all_refs.bib",
        }
    },
}

source for exports takes gitignore style patterns to exclude and include folders.

In addition you can modify the default templates for the pramaana new ... --template= option by storing/editing them as ~/.pramaana/templates/article.bib etc. (The default templates will be dumped in ~./pramaana/templates/ after the first run; you can inspect them beforehand in src/pramaana/core.py::DEFAULT_TEMPLATES.)

Shell Completion

You can get:

  • Command completion: pramaana <tab> shows all available commands
  • Path completion: pramaana show cs/<tab> shows subdirectories
  • Export completion: pramaana export <tab> shows configured export names
  • Template completion: pramaana new bla/foo/bar --template <tab> shows all available templates

[NOTE: --template=<tab> and --template<tab> also work on zsh but not on bash. This is because Claude wrote them and it doesn't seem important enough to bother manually inspecting; just use --template <tab> i.e. with space, on bash.]

After installing, run

pramaana-install-completions

Then for bash, add to your ~/.bashrc:

if [ -d ~/.local/share/bash-completion/completions ]; then
    for f in ~/.local/share/bash-completion/completions/*; do
        . "$f"
    done
fi

For zsh, add to your ~/.zshrc:

fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit
compinit

If you're using oh-my-zsh, this will slow down your startup time. You should instead just add

fpath=(~/.zsh/completion $fpath)

before source $ZSH/oh-my-zsh.sh.

Importing your references

To import from Zotero (or elsewhere), we will need a special kind of .bib export which, for each bib entry, contains the following fields:

  • file = {/path/to/attachment.pdf;/path/to/other_attachment.html}
  • collection = {/collection/subcollection/subsubcollection}

To get this with Zotero you can use the BetterBibTeX plugin with some special settings.

  1. download here then in zotero "install plugin from file"

  2. then in the plugin settings for BetterBibTeX, add this postscript:

if (Translator.BetterTeX && zotero.collections) {
function path(key) {
    const coll = Translator.collections[key]
    if (!coll) return ''
    return `${path(coll.parent)}/${coll.name}`
}

zotero.collections.forEach((key, i) => {
    tex.add({ name: `collection${i > 0 ? i : ''}`, value: path(key) })
})
}
  1. set this citation key formula in the BBT plugin settings: (auth.lower + shorttitle(3,3) + year).replace("@", "") (I think this is necessary, not sure what the default is)

  2. Select My Library in Zotero, then File -> Export Library..., select Format: BetterBibTeX, leave everything unchecked except maybe worker, press OK.

  3. Save the bib file, then import it as

pramaana import /path/to/special_bbt_import.bib [--via ln|cp|mv]

--via determines how the attachments are copied over -- they can be hardlinked, copied, or moved. Default is ln, which is instant like mv as it does not require data to be duplicated, but like cp retains the original files untouched (you can still delete the original files safely, as deletion just unlinks the pointers from the data.)

Development

To set up a development environment:

git clone https://github.com/abhimanyupallavisudhir/pramaana.git
cd pramaana
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows
pip install -e ".[dev]"

TODO

WONTFIX:

  • Make find command work within folders changed to grep
  • Package it to automatically start the docker process
  • remove the storage_format option we don't want it

Metadata

Release files for pramaana 1.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pramaana 1.9.0
File Size Uploaded Provenance
pramaana-1.9.0.tar.gz 19.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pramaana 1.9.0
File Interpreter ABI Platform
pramaana-1.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.1 kB

Release files / pramaana-1.9.0.tar.gz

Download URL pramaana-1.9.0.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2797afc46be806efa37614de4c092b881169a315b0d1c3fc6888cf8619e1329f
BLAKE2b-256 checksum
How to use checksums
f4b036f9fe1dd358b792444cc61567ab28e7a990d0bde9885a17b5894b9e3922
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / pramaana-1.9.0-py3-none-any.whl

Download URL pramaana-1.9.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71a88ffcef0d564c7346b0222900625822e2066fd9556360241052418cc09fc6
BLAKE2b-256 checksum
How to use checksums
0db8882a7e406835703021a861f1fcb59844a2ebd0270e992e9583ccb9163d1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Security for pramaana 1.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page