A PowerShell implementation of the unix fortune program. This project aims to implement many features from the original program with new ideas for more flexibility. Flags -a and -o from the original have been replaced by an approach using arrays of filepaths from config files. This allows not only more specific groupings to seperate fortune files, but also allows fortune files to be independent from a single directory.
- Download the
fortune.ps1script and the default configfortune_config.psd1. - If you don't have any pre-existing fortune files, also download the fortunes directory.
- If you do have pre-existing fortune files, modify the default config to point those files in under the default case. See the example for reference.
- Optional config based quote pooling.
- Directory independent.
- Arrays of filepaths.
- Supports PSD1, JSON/JSONC, TOML, and YAML.
- Length and Pattern parameters.
- Compatible with PowerShell v5.1+.
- Comment-based help for
Get-Helpparsing.
Example of config.psd1
@{
default = @(
"C:\foobar\fortunes\*"
)
TV = @(
"C:\foobar\fortunes\xfiles.txt"
"C:\bazbar\breakingbad.txt"
"D:\path\simpsons.txt"
)
}Please read the Get-Help for example calls and in-depth parameter descriptions.
| Parameter | Alias | Action |
|---|---|---|
| PRIMARY | ||
| File [path] | f | Filepath of Fortune file(s) to pool quotes from. |
| Config [path] | c | Config filepath. Should contain groupings of fortune filepaths. Default is current directory + "\fortune_config.psd1". |
| Group [foo] | g | Group to pool from within config file. Default is "default". |
| SECONDARY | ||
| Long [#] | l | Only use quotes longer than the length specified. |
| Short [#] | s | Only use quotes shorter than the length specified. |
| Length [#] | n/ls | Only use quotes that are exactly the length given. |
| Match [pattern] | m/regex | Print all quotes matching the regex pattern given. |
| Percentage | p | Print filepaths of Fortune files and percentages. |
| Seed [#] | Sets seed for randomization. | |
| Equidistribution | e | Distribute equal probability among the selected Fortune files. |
| Wait | w | Waits before exiting after printing single fortune. |
| UTILITY | ||
| Version | v | Print version info and exit. |
| Help | h | Print help info and exit. |
- Usage of a TOML config file requires PSToml and PowerShell v5.1+.
- Usage of a YAML config file requires powershell-yaml.