• a CLI Bible reference tool •
bib
is a command-line tool that quickly prints Bible verses to the Linux terminal using Bash, along with markdown files for the Bible generated by my BibleGateway-to-Obsidian script. In addition to Bash, it uses external binaries sed, awk, tput, wc, readlink, dirname, clear, jq, and column.
🌟 This project includes the NET translation 🌟 This is possible thanks to the NET translation team's generous copyright which permits free redistribution. If you'd like to use a different translation, see the Other Translations page. Translation support may vary since this program depends on BibleGateway-to-Obsidian.
Table of Contents
For more info on other topics, visit these pages:
- Compatible with Linux, Windows (WSL2), and Android (Termux)
- Verse-by-verse format
- Requested verses in red
- Editorial headings
- New paragraphs begin with an arrow
- Supports viewing multiple verses at once
- Common book abbreviations supported
- An interactive mode that lets you enter chapters and verses directly without typing
bib
each time - Italicized words depending on the translation (displayed in brackets)
- Hyphenate words that are too long for the terminal window
- Automatically scale output with the terminal size
bibs
(by w1ldrabb1t) searches words and phrases then prints the results with bib. See Searching with bibsbibr
(by w1ldrabb1t) randomly prints a Bible verse using bib. See Random verses with bibrbibc
copies chapters of the Bible to the clipboard
Install these dependencies depending on your machine. Most systems come with them pre-installed:
sudo apt update
sudo apt install -y coreutils util-linux sed gawk jq bsdmainutils ncurses-bin
sudo dnf update
sudo dnf install -y coreutils util-linux sed gawk jq ncurses
sudo pacman -Syu coreutils util-linux sed gawk jq ncurses
This program should go into your PATH so that it can be ran anywhere. I made a folder Bin
in my user directory, moved bib to it, and added this line to my ~/.bashrc
:
export PATH=/home/$USER/Bin/:$PATH
As long as you move it to a folder in PATH, it will be fine. You do not have to use the folder I used above.
Next, give execution privileges to bib. Using my folder as an example:
chmod u+x ~/Bin/bib
Finally, move the included folder Bible
to the same PATH folder you moved bib to. More instructions on using other translations can be found in Other Translations.
Here are examples of running the program. Requested verses appear in red to stand out (see the screenshot above):
# Genesis 1
bib gen1
# Genesis 1:1 (and context verses Genesis 1:2 and 1:3)
bib gen1 1
# Genesis 1:1 (no context verses)
bib gen1 1 -n
# Genesis 1:3-4 (and context verses Genesis 1:2, 1:3, 1:5, 1:6)
bib gen1 3 4
# Genesis 1:3-4 (no context verses)
bib gen1 3 4 -n
Both full names and abbreviations of Bible books work in bib. The most common abbreviations from this list from Logos are supported. To see all abbreviations supported by this script, run
bib -a
Any of the following formats work as well, thanks to flexible input handling. Capitalization does not matter:
bib 1cor13 4 7
bib 1cor13 4-7
bib 1cor13:4 7
bib 1cor13:4-7
bib 1 cor 13 4 7
bib 1 cor 13 4-7
bib 1 cor 13:4 7
bib 1 cor 13:4-7
bib 1 Corinthians 13:4-7
bib 1st Corinthians 13:4-7
Verses from the same book can also be grouped using commas without repeating the book name (colons and hyphens can still be replaced with spaces here):
bib matt 2:1, 28:18-20, 1:1-17, 8:5-10, 21:43
To open an interactive prompt (similar to Python), just run bib
by itself. You can enter Bible references without retyping bib
each time. Command history is supported and saved in ~/.bib_history
.
Commands will be entered like this in the interactive mode:
# enter into bib interactive mode
bib
# type Bible references
>>> gen1
>>> gen1 1
>>> gen1 1 2
>>> john3 16 -n
Open bib
in a text editor to adjust several options at the top, including:
- The character used to indicate a new paragraph
- Whether context verses are shown by default
- If enabled, use
-n
to hide context - If disabled, use
-c
to show context
- If enabled, use
- Whether to display output with
less
orcat
Multiple verses can be entered in a single line, and each will print one by one. Use -n
or -c
after individual verses to hide or show context for that verse, or use -N
or -C
to hide or show context for all verses in the current command.
This feature works in both interactive and non-interactive modes. The only limitation is that books with numbers (e.g., 1 Cor.) must not have a space between the number and the book name. Colons and hyphens can still be replaced with spaces here:
A208>>> phil 4:13 1john4:18-19 heb12:7
# hide context verses for only phil4 13
>>> phil4:13 -n 1john4 18 19 heb12 7
# hide all context verses for all selected verses
>>> -N phil 4:13 1john4:18-19 heb12:7 -N
>>> phil 4:13 1john4:18-19 heb12:7 -N
The included script bibs
by w1ldrabb1t lets you search for a word or phrase in the Bible, printing each result one at a time using bib. For multiple-word phrases, wrap them in quotation marks.
To use, put bibs in the same directory as bib and the Bible folder, ideally in your PATH (see Setup).
The included script bibr
by w1ldrabb1t randomly prints a Bible verse to your terminal using bib. It works by finding the last verse in the file, generating a number between 1 and that verse, and then calling bib.
To use, put bibr in the same directory as bib and the Bible folder, ideally in your PATH (see Setup).
Use -n
to hide context verses for a single verse, or -N
to hide context for all verses when selecting multiple in one line. You can also use -v
to enable verbose mode, which displays the bib command being executed.
A cool way to run this script and a fun way to find any Issues is to run this:
for i in {1..1000}; do bibr; done
This repo also includes bibc
, a program that copies entire chapters, reformats them, and makes them easy to paste into Monkeytype. The copied text is kept very basic and looks as it does in the above screenshot
Copying selected verses with bib isn't supported yet, but you can do it like this if you remove the color codes added by the script. Be sure to install xclip
:
bib john3 16|xclip -sel clipboard
I recommend just running bib multiple times in a row similar to this, and then just copying the output from the terminal with your cursor.
One features of this program I spent considerable time refining is automatically hyphenating words that run off the screen. This creates an almost justified text alignment, allowing the text body to scale cleanly across different terminal widths (even extremely small terminals). It handles many edge cases I carefully covered with regex. For example, if character 80 on an 80-width terminal is )
followed by a comma, the program hyphenates the preceding word to maintain alignment. Below are examples of how Bib looks on different terminal sizes.
- Help menu (1)
- Build bibs, bibr, and bibc into bib
- Support for other languages (1)
- Bookmark chapters and verses (1)
- Switch from markdown to XML (1)
- Abbreviations list (1)
- Add instructions if
Bin
path is different (1) - Symbolic link to script (1)
- Type
bib
to enter a console so you don't have to type bib for every verse you want - Allow console mode to take options
- Finish writing Termux setup guide