Local-first Bible study CLI

Lex CLI Docs

Last updated:

Lex reads Scripture, searches local Bible databases, opens interlinear study views, maps cross-references and manuscript witnesses, browses creeds, and exports study work from the terminal.

Prefer a browser? Lex Web is the browser edition of Lex, with the same seven Bible editions.

Version 2.6.5 Python 3.12+ Offline SQLite/JSON runtime data macOS/Linux terminal workflow

What's New In 2.6.5

  • Geneva 1599 text. The Geneva Bible (gen) is now the 1599 text. Releases up to 2.6.4 shipped an older 1587/KJV-like Geneva database. lex -B gen Genesis 1:1 now reads "In the beginning God created the heauen and the earth."
  • Reference parsing. Typographic dashes (John 3:16–18), spaced ranges (John 3:16 - 18) and hyphenated book names (1-chronicles, song-of-solomon) work again.
  • npm launcher. When the launcher finds a newer GitHub release than its own version, it now installs that release instead of failing.
  • Security hardening. Safer text parsers, safe XML import, restricted update downloads and export paths, and Pillow 13 or newer.
  • Dependencies. requirements.txt now matches pyproject.toml, so the npm launcher no longer reinstalls Python packages on every start.

Install And Update

Lex needs Python 3.12 or newer. The recommended install is a full Git checkout because Lex depends on a large local runtime data bundle.

git clone https://github.com/elcafe7/lex.git
cd lex
./setup.sh

setup.sh creates a repo-local virtual environment, installs the Python dependencies, and writes a lex wrapper into ~/.local/bin. That wrapper runs the checkout's lex.py directly.

npm Launcher

For a one-line install, use the npm launcher (Node.js 18 or newer):

npm install -g @n8te_/lex-cli
lex --version

The npm package is a small launcher. On first run it downloads the latest Lex GitHub release, verifies its SHA-256 checksum, creates an isolated Python environment, installs the Python dependencies, and caches the full offline app under your user profile. Later runs reuse that cached install.

lex --npm-version   # Node launcher version
lex --version       # Lex application version

Release Archive

To install from a GitHub release archive instead of git clone, check the archive against its checksum file before unpacking:

curl -LO https://github.com/elcafe7/lex/releases/download/v2.6.5/lex-v2.6.5.tar.gz
curl -LO https://github.com/elcafe7/lex/releases/download/v2.6.5/lex-v2.6.5.tar.gz.sha256
shasum -a 256 -c lex-v2.6.5.tar.gz.sha256

Update Code

git pull
./setup.sh

Update Runtime Data

lex update

lex update is data-only. It syncs manifest-tracked files under runtime-data/ and does not overwrite CLI code.

Reference Syntax

References are intentionally forgiving. Full names, common abbreviations, compact references, and chapter-only references are accepted.

Single verse

lex John 3:16
lex jn 3:16
lex 2 jn 1:2

Chapter

lex Romans 8
lex read John 1
lex Gen 1

Verse range

lex Romans 8:28-39
lex John 3:16–18
lex John 3:16 - 18

Compact and hyphenated

lex jn3:16
lex 1-chronicles 16:34
lex song-of-solomon 2:1

Several references

lex John 3:16, Romans 5:8
lex study John 1:1, John 1:14

One-time Bible selection

lex -B kjv John 3:16
lex -B gen Genesis 1:1
lex -B lxx Genesis 1:1

Command Reference

This section covers the Lex 2.6.5 command surface. Optional flags can usually appear before or after the reference. Most commands show their own help when run without an argument, for example lex search or lex strongs.

Start, Help, Credits

CommandPurpose
lexOpen the main landing screen.
lex helpShow the full command map.
lex --helpShow every flag with a short description.
lex --versionPrint the plain application version for scripts.
lex --npm-versionPrint the npm launcher version (npm installs only).
lex --creditsShow data credits and source acknowledgements.
lex update or lex --updateRefresh manifest-managed runtime data.

Read Scripture

CommandPurpose
lex John 3:16Read a verse with nearby context.
lex read John 3:16Explicit read command for a verse.
lex Romans 8Read a full chapter.
lex --nextMove to the next verse or chapter from the saved history position.
lex --prevMove to the previous verse or chapter from the saved history position.
lex read allRead the top cross-references for the last verse you opened.

History

CommandPurpose
lex historyShow recent Lex commands from the local query history.
lex history --limit 10Show a smaller number of recent commands.
lex history --clearClear the local query history.
lex history clearAlternate clear form.

Study

CommandPurpose
lex study John 1:1Show selected-version context, then source-language study tables, lexicon notes, topical associations, and TSK cross-references.
lex John 3:16 -iQuick study mode using the interlinear flag.
lex study Romans 1:1 --no-animateDisable pauses between study sections.
lex study Romans 1:1 --animateForce pauses between study sections.
lex -B lxx Genesis 1:1 -iExplicit LXX study path. This mode is in progress.
lex -B vulg John 1:1 -iExplicit Vulgate study path. This mode is in progress.
English-version Old Testament study is Masoretic-oriented through the local ESV Hebrew/Aramaic interlinear packet. LXX and Vulgate study data should not auto-populate while studying an English Bible.

Search

CommandPurpose
lex search israelSearch Scripture for a word.
lex search "kingdom of god"Search for a phrase. Exact phrases rank first, then verses containing all terms.
lex search israel --page 2Open a specific result page.
lex search israel --limit 25Change result count per page.
lex search covenant -jeremiahScope search to one book.
lex search beast -daniel-revelationScope search to a book range.
lex search resurrection -ntScope search to a canon group.

Search looks at verse text only, and likely misspellings are corrected and shown in the result footer. A bare book name in the query is searched as text, so use a scope such as -john to search within a book.

Supported group scopes include -ot, -old-testament, -nt, -new-testament, -law, -pentateuch, -torah, -history, -wisdom, -poetry, -major, -major-prophets, -minor, -minor-prophets, -prophets, -gospels, -epistles, -letters, -pauline, and -general-epistles.

Verse Web

CommandPurpose
lex web John 3:16Show the verse plus ranked local cross-reference connections.
lex web Romans 1:1 --limit 8Control the number of cross-reference rows.

Topics, Lexicons, Dictionary

CommandPurpose
lex naves graceOpen a Nave's Topical Bible entry.
lex topic graceAlias for Nave's topic lookup.
lex naves John 3:16Find topical associations for a verse.
lex G3056Look up a Strong's Greek number.
lex H7225Look up a Strong's Hebrew number.
lex strongs G3056Show the lexicon entry plus reverse verse usage from the ESV interlinear index.
lex strongs G3056 --page 2 --limit 25Page through reverse verse usage.
lex strongs G3056 --allShow all reverse verse usage results.
lex strongs loveSearch Strong's entries by English gloss.
lex strongsOpen the Strong's help page.
lex define covenantShow local dictionary and encyclopedia entries.

Commentary And Creeds

CommandPurpose
lex commentary John 3:16Show local commentary notes for a verse (Matthew Henry and John Calvin).
lex commentary Romans 1Show local commentary notes for a chapter.
lex creedOpen the creed and confession navigator.
lex creed niceneOpen a specific creed or confession by search term.
lex creed westminster confessionOpen a longer historical document by name.

Export

CommandPurpose
lex export "John 3:16"Open an interactive export menu.
lex export "Romans 8:28-39" --mode read --format pptxExport read-mode verses to PPTX.
lex export "Romans 8:28-39" --mode read --format pngExport read-mode verses to PNG images.
lex export "John 1:1" --mode study --format pdfExport study packet as PDF.
lex export "John 1:1" --mode study --format docxExport study packet as DOCX.
lex export "John 3:16" --mode web --format pdfExport verse web data as PDF.
lex export "John 3:16" --mode web --format docxExport verse web data as DOCX.

Manuscript Map

Map a verse to the manuscript readings and witnesses Lex knows about, or open a manuscript profile by name or Gregory-Aland number.

CommandPurpose
lex manuscript John 1:1Show available readings and witnesses for a verse.
lex manuscript Isaiah 53:11Old Testament readings work the same way.
lex manuscript P66Open a manuscript profile.
lex manuscript 1QisaaOpen a Dead Sea Scrolls profile.
lex manuscript John 1:1 --limit 25Show more rows.

Lex uses bundled or cached manuscript data first. Missing pieces are fetched one at a time from Lex Web and cached under ~/.cache/lex/manuscripts/ for offline reuse.

Interactive Actions

ModeKeys
Studyn next verse, p previous verse, r read context, w verse web, e export, q done.
Search1-10 study result, r # read result, n/p page, e export, q quit.
Creedsn next section, p previous section, m menu, q quit.
ReadVerse and chapter reads expose export actions in interactive terminals.

Exports

Lex writes exports under ~/Documents/lex_exports. Study packets go under ~/Documents/lex_exports/studies. The app tries to open finished files automatically and prints the path if the desktop blocks that.

ModeFormatsNotes
ReadPNG, PPTXUse --ratio 16:9 or --ratio 1:1 for PNG exports.
StudyDOCX, PDFInteractive study export also offers a PPTX verse slide.
SearchDOCX, PDF, PPTXExports the current result page from interactive search.
Verse WebDOCX, PDFExports verse plus cross-reference connection data.

Bible Versions

Lex ships seven Bible editions. The default is the ESV.

IDEdition
esvEnglish Standard Version
kjvKing James Version (Oxford 1769)
kj16King James Version (1611)
nasbNew American Standard Bible (1995)
genGeneva Bible (1599)
lxxSeptuagint (Rahlfs 1935)
vulg or vulgateClementine Vulgate
CommandPurpose
lex -v nasbSet the default Bible version. It stays until you change it.
lex version kjv or lex bible kjvSame as -v: set the default Bible version.
lex -v gen John 3:16Set the default and read in one step.
lex -B lxx Genesis 1:1Use a Bible version for one command only. Your default does not change.

Themes

Lex chooses a theme from explicit flags, environment variables, saved config, terminal hints, and platform appearance.

CommandPurpose
lex -lightPersist Studio Light theme.
lex -darkPersist Blueprint Technical theme.
lex -autoClear saved theme and return to automatic detection.
LEX_THEME=dark lex John 3:16Override the theme for one command.
LEX_NO_COLOR=1 lex John 3:16Disable Lex color intentionally.

Troubleshooting

SymptomWhat To Check
lex not foundConfirm ~/.local/bin is on PATH and rerun ./setup.sh. For npm installs, confirm the npm global bin folder is on PATH.
Setup or first run failsCheck python3 --version. Lex needs Python 3.12 or newer.
Not sure which version is runningRun lex --version for the Lex app and lex --npm-version for the npm launcher.
Wrong checkout runningRun type -a lex and head -5 ~/.local/bin/lex.
No reference resultTry the full book name, such as lex 1 Corinthians 13.
No study dataThe verse can still be read, but study requires the matching local source-language dataset.
Missing encyclopedia entryThe local ISBE import is incomplete. It currently covers only Volume II (Clement–Heresh).

Developer Backend Overview

lex.py is the active tracked CLI. It owns argument parsing, local SQLite access, JSON loading, terminal rendering, update checks, export generation, and interactive action loops.

Entry Point

main() parses CLI flags and dispatches to LexAgent methods.

Database Wrapper

LexDB is a small SQLite query helper used by read, search, study, creeds, and dictionaries.

Runtime Agent

LexAgent resolves references, opens data stores, lazily loads JSON, renders output, and handles exports.

State

Last navigation position is stored in ~/.lex_history. Recent command history is stored in ~/.lex_query_history. Theme config is stored in ~/.lex_config.json.

Runtime Data

A normal checkout resolves data under runtime-data/. If the runtime bundle is absent, Lex can fall back to ~/bible-lexicon-data for local developer worktrees.

PathUse
runtime-data/lexicon.dbLegacy combined data and update sentinel.
runtime-data/bible_versions/*.dbPer-edition Bible text for read and search: esv, kjv, kj16, nasb, gen (Geneva 1599), lxx, vulg.
runtime-data/esv-data/data/esv/esv-interlinear.jsonESV-backed Hebrew/Greek interlinear rows.
runtime-data/esv-data/data/interlinear/strongs.jsonInterlinear Strong's metadata.
runtime-data/lxx.dbIn-progress LXX morphology study data.
runtime-data/cross_refs.dbTreasury of Scripture Knowledge cross-reference graph.
runtime-data/strongs.dbStrong's lookup data.
runtime-data/strongs_refs.dbReverse Strong's verse usage, built from the ESV interlinear data by scripts/build_strongs_refs_db.py.
runtime-data/naves.dbNave's Topical Bible.
runtime-data/places.dbPlace data.
runtime-data/commentaries/*.dbMatthew Henry and John Calvin commentaries.
runtime-data/dictionary.dbDictionary entries.
runtime-data/encyclopedia.dbISBE encyclopedia entries.
runtime-data/creeds.dbCreed/confession index rows.
runtime-data/theolog-ai/data/historical-documentsJSON fallback for full creed/confession texts.
~/.cache/lex/manuscripts/Manuscript data fetched on demand and kept for offline reuse.

manifest.json lists every runtime data file with its SHA-256 hash. lex update uses it to download only changed files, and the README has a short script to verify a Git checkout against it.

Study Boundaries

Study mode has an important source-tradition boundary.

  • Render the selected Bible version as the context panel first.
  • English Old Testament study remains Masoretic-oriented through ESV Hebrew/Aramaic interlinear data.
  • LXX study is a separate, in-progress path selected explicitly with -B lxx.
  • Vulgate study is a separate, in-progress path selected explicitly with -B vulg.
  • Do not populate LXX or Vulgate study rows while the selected Bible is English.
  • Do not fall back across source traditions by matching only book/chapter/verse suffixes.

CLI Dispatch

main() keeps command routing thin. Feature behavior should live on LexAgent methods.

RouteBackend Method
read or bare referencedisplay_verse() / render_chapter()
study or -idisplay_verse(..., interlinear=True) then display_study()
helpdisplay_command_map()
webdisplay_verse_web()
manuscriptdisplay_manuscript()
commentarydisplay_commentary()
historydisplay_query_history()
searchdisplay_search()
naves / topicdisplay_naves()
strongs / G#### / H####display_strongs() or English Strong's search
defineDictionary plus encyclopedia lookup
creeddisplay_creed_navigator()
exportprompt_bulk_export() or handle_bulk_export()

Verification

Minimum local checks after CLI changes:

python3 -m py_compile ./lex.py
python3 ./lex.py --version
python3 ./lex.py read John 3:16
python3 ./lex.py history --limit 5
python3 ./lex.py -B gen Genesis 1:1
python3 ./lex.py study Genesis 1:1 --no-animate
python3 ./lex.py -B lxx Genesis 1:1 -i --no-animate
python3 ./lex.py search israel --limit 2
python3 ./lex.py strongs G3056 --limit 2
python3 ./lex.py define heliodorus

Before changing install behavior, verify the local wrapper target:

type -a lex
head -5 ~/.local/bin/lex