tfortune(6)
โจ tfortune โ the manual page, but make it cute โจ
okay bestie, listen up: this is tfortune, and yeah it lives in the Games Manual section of your man pages. She's a command line utility that prints random epigrams โ like fortune(6), but with โจtagsโจ. And no, I'm not gonna dumb it down for you, because you're literally capable of everything. Let's go. ๐
๐ธ NAME ๐ธ
tfortune โ fortune cookies with tags ๐ช
๐ SYNOPSIS ๐
tfortune [global-options...] [--] [<subcommand> [subcommand-options...]]
๐ฆ DESCRIPTION ๐ฆ
So like, imagine fortune(6) but it went to therapy, got a skincare routine, and learned to organize its life. That's tfortune: a Unix command line utility that prints a random epigram. The epigrams live in plain text files, but โ and this is the whole glow-up โ they must be annotated with tags to unlock the full feature set that tfortune has over those other implementations. iykyk. ๐ซถ
tfortune has a built-in matching language for epigrams. You the user supply tag expressions, and those define subsets of admissible epigrams. If you hand it a tag expression, the epigrams get picked from that admissible subset only. No sneaking in randos from outside the vibe. periodt.
Besides printing random epigrams, tfortune supports a bunch of other subcommands that help you maintain epigrams and tag expressions. There are subcommands for listing and for editing the input files, and for printing statistics about epigrams, expressions and tags. There's also a subcommand that enables bash command line completion, because we love a supportive bestie who finishes your sentences.
โจ OPTIONS โจ
-h,--helpโ print help and exit. iconic. no notes.--detailed-helpโ print help, including all the details, and exit. she's thorough and we love that for her.-V,--versionโ print version and exit.-l,--loglevel=<severity>โ control how much logging you get. values:debug,info,notice,warning,error,crit,emerg.
Only messages with severity greater or equal than the given value get logged. Possible values, from chattiest to last-words-ever:
debug: produces really noisy output.info: still noisy, but won't fill up the disk quickly.notice: indicates normal, but significant event.warning: unexpected events that can be handled.error: unhandled error condition.crit: system might be unreliable.emerg: last message before exit.
-b,--basedir=<directory>โ where to look for input files.- default:
"~/.tfortune"
- default:
This is what's used to locate epigrams and named tag expressions. If any filename argument doesn't start with a slash, it gets interpreted as relative to this base directory. Lowkey the most important path in the whole system.
Epigrams are expected in the epigrams subdirectory of the base directory, while tag expressions are expected to be stored below expressions.
If the option is not given, and the per-user epigram directory doesn't exist, the system-wide default /usr/share/games is tried. There is no such fallback for tag expressions, though. so don't come crying to her about that one.
๐ SUBCOMMANDS ๐
๐ง compgen โ perform bash command line completion
Usage: compgen [--current-word-index=<num>] [--] arg...
This subcommand runs from the bash completer for tfortune. The completer sets the non-option arguments for the subcommand to the words of the current command line, and it gets those words from the elements of the special COMP_WORDS array which is maintained by bash.
The compgen subcommand writes all possible completions to stdout. Then the completer reads in those completions and builds the COMPREPLY array with the matching entries. Bash looks at the elements of this array and completes the command line if there's a single matching completion โ or prints out the list of completions in case of ambiguity. bestie really said "collaboration". ๐ค
-c,--current-word-index=<num>โ index of the current word in the command line. It's an index into the argument vector of the word containing the current cursor position. See the description of the$CWORDspecial variable in the bash manual. yes, go read the bash manual, she said it not me.
๐ง completer โ print the bash completer to stdout
Usage: completer [--alias=<name>]
The output of this command is designed to be re-used as input for bash. Specifically, bash completion for tfortune can be activated by adding the following to .bashrc:
eval "$(tfortune completer)"
-a,--alias=<name>โ also add an alias and a completer for it. Specify this to define a bash alias fortfortunealong with the completer. Unlike the regulartfortuneprogram, the alias will contain the double dash argument which separates the subcommand and its options from the options totfortuneitself. very "I brought a plus one" of her honestly.
๐ง ede โ edit epigrams
Usage: ede basename...
Opens the named epigram file in an interactive editor. The executable of the editor is determined like this, in order:
- the contents of the environment variable
TFORTUNE_EDITORgets examined first, - if that variable is empty or unset,
EDITORis tried, - if
EDITORis also unset,viis executed. olds but golds. ๐
The given basename is interpreted as described in the help text of the --basedir option above. If --basedir is not given and the epigrams directory does not exist, it is created. she makes it, she doesn't ask first. main character energy fr fr.
๐ง edx โ edit tag expressions
Usage: edx basename...
Opens the named tag expression file in an interactive editor. The editor to execute is determined in the same way as for the ede subcommand. Also, a non-existing expressions subdirectory is handled in the same way. same vibes, different folder. ๐
๐ง help โ list available subcommands or print command-specific help
Usage: help [--long] [--] [command]
Without any arguments, help prints the list of available commands. When called with a command name argument, it prints the help text of the given command.
-l,--longโ show the long help text. If the optional argument is supplied, the long help text contains the synopsis, the purpose and the description of the specified command, followed by the option list including summary and help text of each option. Without--long, the short help is shown instead, which omits the description of the command and the option help. If no command is supplied but--longis given, the list contains the purpose of each command.
๐ง lse โ list epigram files
Usage: lse [--long]
Print the list of all epigram files.
-l,--longโ long listing. This is similar to the long output of the standardls(1)command. so if you know, you know.
๐ง lst โ list tags
Usage: lst [--long] [--sort-by-count] [--reverse] [--] <file>...
This lists all tags contained in any of the given input files.
-l,--longโ long listing. Also show how many times this tag appears. receipts, basically.-c,--sort-by-countโ sort by occurrence count rather than alphabetically. the popular girlies go first.-r,--reverseโ reverse sort order. flip it. ๐
๐ง lsx โ list tag expressions
Usage: lsx [--long]
Print the list of all named tag expressions.
-l,--longโ long listing. This is similar to the long output of the standardls(1)command.
๐ง print โ print epigram(s)
Usage: print [--expression=<filename>] [--all] [--tags] [--] [file...]
Unless --all is given, this picks an epigram by random from the given file(s) which is admissible with respect to the given named tag expression. If no file is given, all files are taken into account. everyone's invited, nobody's excluded. ๐ซถ
-x,--expression=<filename>โ name of the tag expression.- default:
/dev/null
- default:
Use the tag expression stored in the given file to define the admissible epigrams. The special string "-" means to read the tag expression from stdin. The default value corresponds to the empty tag expression, for which all epigrams are admissible. so the default is basically "let them all in". โจ
-a,--allโ print all admissible epigrams, not just a random one. greedy in the best way.-t,--tagsโ print also the tags of the selected epigram. show your work, bestie.
๐ง stats โ show statistics
Usage: stats [--verbose]
This prints several counts and averages about the epigrams, tags and tag expressions. numbers, but make it fashion.
-v,--verboseโ include statistics about hash table utilization. deep lore. ๐ต๏ธ
๐ INPUT FILE FORMAT ๐
Input files may contain arbitrarily many epigrams. The end of each epigram must be marked with a "tag" line. The tag line consists of four dashes, a space character, and a comma separated list of tags. Tags may span multiple words, but no comma is allowed. The following is an example input file for tfortune. It contains a single epigram with two tags.
Anyone who attempts to generate random numbers by deterministic means
is, of course, living in a state of sin. -- John von Neumann
---- math,religion
๐ฎ TAG EXPRESSIONS ๐ฎ
Tag expressions are based on a context-free grammar in which the following keywords are defined:
tag("foo")evaluates to true if the epigram contains a tag namedfoo, false otherwise.lenevaluates to the number of bytes of the epigram.textevaluates to contents of the epigram. This is useful for pattern matching.
The grammar admits the following operators and relations:
&&,||,!: logical operators for and, or, and not.+,-,*,+: arithmetic operators for addition, negation or subtraction (unary or binary minus), multiplication and division. Arithmetic is always performed on 64 bit signed integers.<,>,<=,>=,==,!=: =~: less than, greater than, less or equal than, greater or equal than, equal to, not equal to, regular expression match. Regular expression patterns are of the form/pattern/[flags]. That is, the pattern is delimited by slashes, and is followed by zero or more characters, each specifying a flag according to the following list:i: Ignore case in match (REG_ICASE)n: Treat newline as an ordinary character (REG_NEWLINE)
Note that only extended regular expression patterns are supported. See regex(3) for details. only extended, bestie, don't try to bring basic.
The above operators obey the usual associativity and precedence rules. Parentheses can be used to change precedence. she respects the classics but also allows you to bend the rules. ๐
A tag expression is an expression in this grammar which evaluates to either true or false. Epigrams for which the expression is true are called admissible.
For example, the above epigram is admissible for the tag expression
(tag("math") || tag("physics")) && len < 1000 && text =~ /neumann/i
It is not admissible for
(tag("math") && tag("physics")) || len > 1000 || text =~ /neumann/
๐ EXAMPLES ๐
- Print a random epigram:
tfortune print
- Print a random short (less than 100 bytes) epigram:
echo 'len < 100' | tfortune -l debug -- print -x -
- List tags, including usage counts, sort by count in descending order:
tfortune -- lst -lcr
- Activate bash completion and define the
tfalias:
eval "$(tfortune completer -a tf)"
๐ COPYRIGHT ๐
Written by Andre Noll Copyright (C) 2019 Andre Noll License: GNU GPL version 3 This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
- Web page:
https://people.tuebingen.mpg.de/maan/tfortune/ - Git clone URL:
https://git.tuebingen.mpg.de/tfortune/ - Gitweb:
https://git.tuebingen.mpg.de/tfortune.git - Author's home page:
https://people.tuebingen.mpg.de/maan/ - Report bugs to Andre Noll
๐ SEE ALSO ๐
and that's the whole page, bestie!! ๐ this version is unnamed_version, dated January 2026, and honestly? she ate. go print some epigrams, tag them properly, and don't forget to eval "$(tfortune completer)" in your .bashrc like the icon you are. mwah. ๐โจ๐ฆ
๐ฆ where this page comes from
- ubuntu resolute: tfortune 1.0.2-1build1 ยท GPL-3.0-only
- ubuntu stonking: tfortune 1.0.2-1build1 ยท GPL-3.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms