42/README.md
2023-03-18 23:51:10 -04:00

39 lines
2.4 KiB
Markdown

## Description
**42** is a silly little utility similar in nature to the Unix *fortune* command
of old, if it was much simpler and only provided Douglas Adams quotes primarily
from the HitchHiker's guide.
## History
The original 42 was written in C for [HitchHiker Linux](https://hitchhiker-linux.org)
back when I was first learning how to program in that language. This rewrite in
Rust preserves much of the simplicity of the original while being more robust and
providing more flexibility in where it's data files are stored.
## Installation
To build *42* you will need a Rust toolchain. The only explicit dependency besides
`std` is the `rand` crate, and the code is simple without much reliance on bleeding
edge features, so there should be some flexibility in what version of Rust is
used. The included `Makefile` wraps the commands used and will install the data
files and Unix man pages into the proper locations. Should you wish to package
this little gem for your own distro (I'm not sure why, but maybe you would?) then
all of the files can be installed into a destdir by passing the `DESTDIR` environment
variable to `make install`.
```SH
make && make install
```
## Usage
Most commonly you would call this program from your shell startup files by adding
`42 &` to *~/.bashrc* or *~/.zshrc*, or whatever file your shell happens to use.
This will give you a DA quote every time you log in or open a new terminal window.
## Licensing
The code is GPL3. The data files are copyrighted works of Douglas Adams. Since he's
dead, and was an avowed atheist, I have no moral qualms that he has any objection
to my sharing them with this program. Governments may disagree. Such is liff.
## Adding more *cookies*
Unlike the *fortune* program, which parsed specially formatted data files, *42*
places each *cookie* in a plain text file which is simply read and printed to
stdout exactly as it appears in the file. The included files are sequentially
numbered, but this is not strictly required. To add more *cookies* simply type
(or, let's face it, you're going to cut and paste here) each message into it's
own file and drop it into an appropriate directory. 42 will look for a data
directory named (surprise) 42 in $(XDG_DATA_DIRS) if it exists, or else the
default of "/usr/local/share:/usr/share". It will also look in *~/.local/share*.
If multiple data directories are found, it will read from all of them.