<h1 style="text-align: left;">
<img src="res/rfortune.svg" width="90" style="vertical-align: middle; margin-right: 8px;" alt="rFortune Logo"/>
rFortune
</h1>
**rFortune** is a modern, cross-platform reimplementation of the classic Unix `fortune` program, written in Rust.
It displays a random quote or witty phrase from a plain text file, making it perfect for terminal startup messages,
scripting, or just a bit of inspiration.

[](LICENSE)
[](https://github.com/umpire274/rFortune/releases)
[](https://github.com/umpire274/rfortune/releases/latest)
---
## β¨ New in v0.5.2
### π Configuration system improvements
- Configuration filename renamed from config.yaml β rfortune.conf for better clarity and portability.
- Automatic migration from legacy config.yaml to the new format β the old file is safely backed up as config.yaml.bak.
- Added the new subcommand config edit:
- rfortune config edit β opens rfortune.conf using the systemβs default text editor.
- rfortune config edit --editor <name|path> β opens it with a specific editor (e.g. vi, nano, code).
- Automatic detection of preferred editors via $VISUAL and $EDITOR environment variables.
- Default fallback editors are nano (macOS/Linux) and notepad (Windows).
### π¨ Improved CLI feedback
- Introduced the new ConsoleLog class for rich, colored terminal output:
- βΉ Info, β
Success, β οΈ Warning, β Error
- Unified message style and improved feedback during configuration, cache, and fortune file operations.
---
## π Features
- β
Cross-platform: works on **Linux**, **Windows**, **macOS Intel** and **Apple Silicon**
- β‘ Fast and lightweight (native Rust binary)
- π Simple input format: one or more lines per fortune, separated by `%`
- πΉ UTF-8 support for multilingual content
- π§© Easily extensible
- π§ Built-in cache system to avoid showing the same fortune twice in a row
- β¨ New CLI with subcommands for config, file initialization and cache management
---
## π¦ Installation
[](https://repology.org/project/rfortune/versions)
### π§ AUR (Arch Linux)
[](https://aur.archlinux.org/packages/rfortune)
```bash
yay -S rfortune
# or
paru -S rfortune
```
### πΊ Homebrew (macOS/Linux)
[](https://github.com/umpire274/homebrew-tap)
```bash
brew tap umpire274/tap
brew install rfortune
```
### π¦ Crates.io (Rust)
[](https://crates.io/crates/rfortune)
```bash
cargo install rfortune
```
---
## π₯ Download
Precompiled binaries are available in the [Releases](https://github.com/umpire274/rfortune/releases) section.
| Windows | x86_64 | `rfortune-<version>-x86_64-pc-windows-msvc.zip` |
| Linux | x86_64 | `rfortune-<version>-unknown-linux-gnu.tar.gz` |
| macOS Intel Architecture | x86_64 | `rfortune-<version>-x86_64-apple-darwin.tar.gz` |
| macOS Apple Silicon | aarch64 | `rfortune-<version>-aarch64-apple-darwin.tar.gz` |
---
## π GPG Signature
All release archives are cryptographically signed with GPG.
- `.sig` files contain the ASCII-armored detached signature for the corresponding archive.
- You can verify the archive with:
```bash
gpg --verify rfortune-<version>-<target>.tar.gz.sig rfortune-<version>-<target>.tar.gz
```
---
## π Public Key
The releases are signed with the following GPG key:
* Key ID: 423FABCE0A1921FB
* Fingerprint: 8118 9716 9512 2A32 1F3D C04C 423F ABCE 0A19 21FB
* Download: https://github.com/umpire274.gpg
To import the key from a keyserver:
```sh
gpg --recv-keys 423FABCE0A1921FB
```
Or from OpenPGP server:
```sh
gpg --keyserver keys.openpgp.org --recv-keys 423FABCE0A1921FB
```
Then verify the fingerprint:
```sh
gpg --fingerprint 423FABCE0A1921FB
```
---
## π Usage
```sh
rfortune [OPTIONS]
rfortune <SUBCOMMAND>
```
Running `rfortune` without subcommands prints a random fortune from the default file (`rfortune.dat`).
---
## π§© Options & Subcommands
| `-f`, `--file <PATH>` | Use a custom fortune file instead of the default |
| `config init` | Create the configuration file with default options |
| `config edit [--editor <E>]` | Open the configuration file in the systemβs default or a specified editor |
| `file init` | Create a sample default fortune file (`rfortune.dat`) |
| `cache clear` | Remove all cached last-used fortunes |
| `-V`, `--version` | Show version information |
| `-h`, `--help` | Show help message |
---
## π‘ Examples
```bash
# Print a random fortune from the default file (rfortune.dat)
rfortune
# Print a random fortune from a specific file
rfortune --file ~/fortunes/misc
# Create the default configuration file in the user data directory
rfortune config init
# Open the configuration file in the systemβs default text editor
rfortune config edit
# Open the configuration file with a specific editor (e.g. vi, nano, code)
rfortune config edit --editor vi
# Create a sample default fortune file (rfortune.dat)
rfortune file init
# Clear all cached last-used fortunes
rfortune cache clear
```
---
## π File Format
Each fortune must be on one or more lines separated by `%`, like so:
```txt
%
The best way to get a good idea is to get a lot of ideas.
%
Do or do not. There is no try.
%
To iterate is human, to recurse divine.
%
```
You may optionally add a title at the top of the file by starting the first line with #. The title will be printed
before the random quote:
```txt
# Murphy's Laws
%
Anything that can go wrong will go wrong.
%
If there's a possibility of several things going wrong, the one that will cause the most damage will be the one to go wrong.
%
```
---
## π License
This project is licensed under the MIT License.
Β© 2025 Alessandro Maestri
---
## π‘ Contributing
Pull requests are welcome! If youβd like to add support for more languages, improve performance, or fix bugs, feel free
to fork the repo and contribute.
---
## π Acknowledgments
Inspired by the classic BSD fortune program. Built with β€οΈ in Rust.