forked from dylanaraps/pure-bash-bible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added build files to turn the bible into a book
- Loading branch information
1 parent
dbed16c
commit e0aadbd
Showing
23 changed files
with
1,907 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Turn the single document bible into a book separated by chapters. | ||
|
||
main() { | ||
rm -rf manuscript | ||
mkdir -p manuscript | ||
|
||
# Split the README.md into chapters based on markers. | ||
while IFS=$'\n' read -r line; do | ||
[[ "$chap" ]] && chapter[$i]+="$line"$'\n' | ||
[[ "$line" == "<!-- CHAPTER START -->" ]] && chap=1 | ||
[[ "$line" == "<!-- CHAPTER END -->" ]] && { chap=; ((i++)); } | ||
done < README.md | ||
|
||
# Write the chapters to separate files. | ||
for i in "${!chapter[@]}"; do | ||
: "${chapter[$i]/$'\n'*}"; : "${_/\# }"; : "${_,,}" | ||
printf '%s\n' "${chapter[$i]}" > "manuscript/chapter${i}.txt" | ||
printf '%s\n' "chapter${i}.txt" >> "manuscript/Book.txt" | ||
done | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
chapter0.txt | ||
chapter1.txt | ||
chapter2.txt | ||
chapter3.txt | ||
chapter4.txt | ||
chapter5.txt | ||
chapter6.txt | ||
chapter7.txt | ||
chapter8.txt | ||
chapter9.txt | ||
chapter10.txt | ||
chapter11.txt | ||
chapter12.txt | ||
chapter13.txt | ||
chapter14.txt | ||
chapter15.txt | ||
chapter16.txt | ||
chapter17.txt | ||
chapter18.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Table of Contents | ||
|
||
<!-- vim-markdown-toc GFM --> | ||
|
||
* [Strings](#strings) | ||
* [Trim leading and trailing white-space from string](#trim-leading-and-trailing-white-space-from-string) | ||
* [Trim all white-space from string and truncate spaces](#trim-all-white-space-from-string-and-truncate-spaces) | ||
* [Use regex on a string](#use-regex-on-a-string) | ||
* [Split a string on a delimiter](#split-a-string-on-a-delimiter) | ||
* [Change a string to lowercase](#change-a-string-to-lowercase) | ||
* [Change a string to uppercase](#change-a-string-to-uppercase) | ||
* [Trim quotes from a string](#trim-quotes-from-a-string) | ||
* [Strip all instances of pattern from string](#strip-all-instances-of-pattern-from-string) | ||
* [Strip first occurrence of pattern from string](#strip-first-occurrence-of-pattern-from-string) | ||
* [Strip pattern from start of string](#strip-pattern-from-start-of-string) | ||
* [Strip pattern from end of string](#strip-pattern-from-end-of-string) | ||
* [Check if string contains a sub-string](#check-if-string-contains-a-sub-string) | ||
* [Check if string starts with sub-string](#check-if-string-starts-with-sub-string) | ||
* [Check if string ends with sub-string](#check-if-string-ends-with-sub-string) | ||
* [Arrays](#arrays) | ||
* [Reverse an array](#reverse-an-array) | ||
* [Remove duplicate array elements](#remove-duplicate-array-elements) | ||
* [Random array element](#random-array-element) | ||
* [Cycle through an array](#cycle-through-an-array) | ||
* [Toggle between two values](#toggle-between-two-values) | ||
* [Loops](#loops) | ||
* [Loop over a range of numbers](#loop-over-a-range-of-numbers) | ||
* [Loop over a variable range of numbers](#loop-over-a-variable-range-of-numbers) | ||
* [Loop over an array](#loop-over-an-array) | ||
* [Loop over an array with an index](#loop-over-an-array-with-an-index) | ||
* [Loop over the contents of a file](#loop-over-the-contents-of-a-file) | ||
* [Loop over files and directories](#loop-over-files-and-directories) | ||
* [File handling](#file-handling) | ||
* [Read a file to a string](#read-a-file-to-a-string) | ||
* [Read a file to an array (*by line*)](#read-a-file-to-an-array-by-line) | ||
* [Get the first N lines of a file](#get-the-first-n-lines-of-a-file) | ||
* [Get the last N lines of a file](#get-the-last-n-lines-of-a-file) | ||
* [Get the number of lines in a file](#get-the-number-of-lines-in-a-file) | ||
* [Count files or directories in directory](#count-files-or-directories-in-directory) | ||
* [Create an empty file](#create-an-empty-file) | ||
* [Extract lines between two markers](#extract-lines-between-two-markers) | ||
* [File Paths](#file-paths) | ||
* [Get the directory name of a file path](#get-the-directory-name-of-a-file-path) | ||
* [Get the base-name of a file path](#get-the-base-name-of-a-file-path) | ||
* [Variables](#variables) | ||
* [Assign and access a variable using a variable](#assign-and-access-a-variable-using-a-variable) | ||
* [Escape Sequences](#escape-sequences) | ||
* [Text Colors](#text-colors) | ||
* [Text Attributes](#text-attributes) | ||
* [Cursor Movement](#cursor-movement) | ||
* [Erasing Text](#erasing-text) | ||
* [Parameter Expansion](#parameter-expansion) | ||
* [Indirection](#indirection) | ||
* [Replacement](#replacement) | ||
* [Length](#length) | ||
* [Expansion](#expansion) | ||
* [Case Modification](#case-modification) | ||
* [Default Value](#default-value) | ||
* [Brace Expansion](#brace-expansion) | ||
* [Ranges](#ranges) | ||
* [String Lists](#string-lists) | ||
* [Arithmetic](#arithmetic) | ||
* [Simpler syntax to set variables](#simpler-syntax-to-set-variables) | ||
* [Ternary tests](#ternary-tests) | ||
* [Traps](#traps) | ||
* [Do something on script exit](#do-something-on-script-exit) | ||
* [Ignore terminal interrupt (CTRL+C, SIGINT)](#ignore-terminal-interrupt-ctrlc-sigint) | ||
* [React to window resize.](#react-to-window-resize) | ||
* [Do something before every command.](#do-something-before-every-command) | ||
* [Do something when a shell function or a sourced file finishes executing](#do-something-when-a-shell-function-or-a-sourced-file-finishes-executing) | ||
* [Performance](#performance) | ||
* [Disable Unicode](#disable-unicode) | ||
* [Obsolete Syntax](#obsolete-syntax) | ||
* [Shebang](#shebang) | ||
* [Command Substitution](#command-substitution) | ||
* [Function Declaration](#function-declaration) | ||
* [Internal Variables](#internal-variables) | ||
* [Get the location to the `bash` binary](#get-the-location-to-the-bash-binary) | ||
* [Get the version of the current running `bash` process](#get-the-version-of-the-current-running-bash-process) | ||
* [Open the user's preferred text editor](#open-the-users-preferred-text-editor) | ||
* [Get the name of the current function](#get-the-name-of-the-current-function) | ||
* [Get the host-name of the system](#get-the-host-name-of-the-system) | ||
* [Get the architecture of the Operating System](#get-the-architecture-of-the-operating-system) | ||
* [Get the name of the Operating System / Kernel](#get-the-name-of-the-operating-system--kernel) | ||
* [Get the current working directory](#get-the-current-working-directory) | ||
* [Get the number of seconds the script has been running](#get-the-number-of-seconds-the-script-has-been-running) | ||
* [Get a pseudorandom integer](#get-a-pseudorandom-integer) | ||
* [Information about the terminal](#information-about-the-terminal) | ||
* [Get the terminal size in lines and columns (*from a script*)](#get-the-terminal-size-in-lines-and-columns-from-a-script) | ||
* [Get the terminal size in pixels](#get-the-terminal-size-in-pixels) | ||
* [Get the current cursor position](#get-the-current-cursor-position) | ||
* [Conversion](#conversion) | ||
* [Convert a hex color to RGB](#convert-a-hex-color-to-rgb) | ||
* [Convert an RGB color to hex](#convert-an-rgb-color-to-hex) | ||
* [Code Golf](#code-golf) | ||
* [Shorter `for` loop syntax](#shorter-for-loop-syntax) | ||
* [Shorter infinite loops](#shorter-infinite-loops) | ||
* [Shorter function declaration](#shorter-function-declaration) | ||
* [Shorter `if` syntax](#shorter-if-syntax) | ||
* [Simpler `case` statement to set variable](#simpler-case-statement-to-set-variable) | ||
* [Other](#other) | ||
* [Use `read` as an alternative to the `sleep` command](#use-read-as-an-alternative-to-the-sleep-command) | ||
* [Check if a program is in the user's PATH](#check-if-a-program-is-in-the-users-path) | ||
* [Get the current date using `strftime`](#get-the-current-date-using-strftime) | ||
* [Generate a UUID V4](#generate-a-uuid-v4) | ||
* [Progress bars](#progress-bars) | ||
* [Get the list of functions from your script](#get-the-list-of-functions-from-your-script) | ||
* [Bypass shell aliases](#bypass-shell-aliases) | ||
* [Bypass shell functions](#bypass-shell-functions) | ||
* [Afterword](#afterword) | ||
|
||
<!-- vim-markdown-toc --> | ||
|
||
<!-- CHAPTER END --> | ||
|
Oops, something went wrong.