{"id":24541402,"url":"https://github.com/HubTou/fortune","last_synced_at":"2025-10-03T17:30:55.255Z","repository":{"id":57453789,"uuid":"394081267","full_name":"HubTou/fortune","owner":"HubTou","description":"Print a random, hopefully interesting, adage (FULL BSD fortune re-implementation in Python)","archived":false,"fork":false,"pushed_at":"2021-09-26T09:15:34.000Z","size":84,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-18T09:08:56.933Z","etag":null,"topics":["command-line-tool","fortune","fortune-cookies","fortune-format","learning-python","learning-unix","pnu-project","python","quote","quotes","quotes-application","shell","tools","unix","unix-command","utility"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HubTou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-08T22:28:03.000Z","updated_at":"2024-11-24T15:40:19.000Z","dependencies_parsed_at":"2022-08-29T10:41:20.430Z","dependency_job_id":null,"html_url":"https://github.com/HubTou/fortune","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubTou%2Ffortune","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubTou%2Ffortune/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubTou%2Ffortune/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubTou%2Ffortune/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HubTou","download_url":"https://codeload.github.com/HubTou/fortune/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235161543,"owners_count":18945540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line-tool","fortune","fortune-cookies","fortune-format","learning-python","learning-unix","pnu-project","python","quote","quotes","quotes-application","shell","tools","unix","unix-command","utility"],"created_at":"2025-01-22T18:17:39.248Z","updated_at":"2025-10-03T17:30:49.954Z","avatar_url":"https://github.com/HubTou.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Installation\npip install [pnu-fortune](https://pypi.org/project/pnu-fortune/)\n\n# FORTUNE(6)\n\n## NAME\nfortune — print a random, hopefully interesting, adage\n\n## SYNOPSIS\n**fortune**\n\\[-acCDefilosw\\]\n\\[-m pattern\\]\n\\[-n length\\]\n\\[-t tries\\]\n\\[--debug\\]\n\\[--help|-?\\]\n\\[--version\\]\n\\[--\\]\n\\[\\[N%\\] file/directory/all\\]\n\n## DESCRIPTION\nWhen **fortune** is run with no arguments it prints out a random epigram from the *fortunes* database.\nEpigrams are divided into several categories, where each category is subdivided into those which are potentially offensive and those which are not.  \n\n### OPTIONS\nThe options are as follows:\n\nOption|Use\n---|---\n-a|Choose from all lists of maxims, both offensive and not (See the *-o* option for more information on offensive fortunes).\n-c|Show the cookie file from which the fortune came.\n-C|Compatibility mode. Try to imitate the original BSD fortune command display as closely as possible.\n-D|Enable additional debugging output. Specify this option multiple times for more verbose output (unused in this re-implementation).\n-e|Consider all fortune files to be of equal size (see discussion below on multiple files).\n-f|Print out the list of files which would be searched, but do not print a fortune.\n-i|Ignore case for *-m patterns*.\n-l|Long dictums only. See *-n* on how ''long'' is defined.\n-m pattern|Print out all fortunes which match the regular expression pattern. See regex(3) for a description of patterns.\n-n length|Set the longest fortune length (in characters) considered to be ''short'' (the default is 160). All fortunes longer than this are considered ''long''.\n-o|Choose only from potentially offensive aphorisms. This option is superseded by *-a*.\u003cbr\u003e\u003cbr\u003e... let us keep in mind the basic governing philosophy\u003cbr\u003eof The Brotherhood, as handsomely summarized in these words:\u003cbr\u003ewe believe in healthy, hearty laughter -- at the expense of\u003cbr\u003ethe whole human race, if needs be.\u003cbr\u003eNeeds be.\u003cbr\u003e--H. Allen Smith, \"Rude Jokes\"\n-s|Short apophthegms only. See *-n* on how ''short'' is defined.\n-t tries|Set the maximum number of attempts while searching for a ''short'' or ''long'' fortune (the default is 10).\n-w|Wait before termination for an amount of time calculated from the number of characters in the message. This is useful if it is executed as part of the logout procedure to guarantee that the message can be read before the screen is cleared.\n--debug|Enable debug mode\n--help\\|-?|Print usage and a short help message and exit\n--version|Print version and exit\n--|Options processing terminator\n\nThe user may specify alternate sayings.\nYou can specify a specific file, a directory which contains one or more files, or the special word *all* which says to use all the standard databases.\nAny of these may be preceded by a percentage, which is a number N between 0 and 100 inclusive, followed by a ‘%’.\nIf it is, there will be an N percent probability that an adage will be picked from that file or directory. \nIf the percentages do not sum to 100, and there are specifications without percentages, the remaining percent will apply to those files and/or directories, in which case the probability of selecting from one of them will be based on their relative sizes.\n\nAs an example, given two databases funny and not-funny, with funny twice as big, saying\n\n    fortune funny not-funny\n\nwill get you fortunes out of funny two-thirds of the time. The command\n\n    fortune 90% funny 10% not-funny\n\nwill pick out 90% of its fortunes from funny (the “10% not-funny” is unnecessary, since 10% is all that is left).\nThe *-e* option says to consider all files equal; thus\n\n    fortune -e funny not-funny\n\nis equivalent to\n\n    fortune 50% funny 50% not-funny\n\n## ENVIRONMENT\nVariable|Use\n---|---\nFORTUNE_PATH|The search path for the data files. It is a colon-separated list of directories in which fortune looks for datafiles. If not set it will default to */usr/share/games/fortune:/usr/local/share/games/fortune*.\u003cbr\u003e\u003cbr\u003eUnder a Posix system, *$HOME/.local/share/games/fortune* will also be added to the default, while *%HOMEPATH%/appdata/roaming/python/share/games/fortune:%HOMEPATH%\\appdata\\local\\programs\\python\\pythonXX\\share\\games\\fortune* will be added under a Windows system.\u003cbr\u003e\u003cbr\u003eIf none of the directories specified exist, it will print a warning and exit. Note that by default, fortune only searches for a *fortunes* file, instead of all files in its FORTUNE_PATH.\nFORTUNE_SAVESTATE|If set, fortune will save some state about what fortune it was up to on disk (unused in this re-implementation, as it requires root access to the fortune directories).\nFORTUNE_COMPAT|Compatibility mode. If set, try to imitate the original BSD fortune command display as closely as possible.\nFORTUNE_DEBUG|Debug mode. If set, print some debug messages.\n\n## FILES\nPath|Description\n---|---\n/usr/share/games/fortune/\\*|the fortunes databases (those files ending “-o” contain the offensive fortunes)\n/usr/local/share/games/fortune/\\*|Additional fortunes\n\nWe offer many data files for this utility in several additional packages, a few of them already installed as a dependency to this one.\n\n## EXIT STATUS\nThe **fortune** utility exits 0 on success, and \u003e0 if an error occurs.\nIn particular, if *-l*, *-m*, or *-s* is specified, failure to find a matching citation in the selected files counts as an error.\n\n## EXAMPLES\nBoxing the fortune output with [echobox(1)](https://github.com/HubTou/echobox/blob/main/README.md):\n\n```\n/usr/local/bin/fortune unix-philosophy unix-quotes | echobox -S single\n```\n\n## SEE ALSO\n[cowsay(1)](https://linux.die.net/man/1/cowsay),\n[echobox(1)](https://github.com/HubTou/echobox/blob/main/README.md),\n[regex(3)](https://www.freebsd.org/cgi/man.cgi?query=regex\u0026sektion=3),\n[strfile(8)](https://github.com/HubTou/strfile/blob/main/README.md)\n\n## STANDARDS\nThe **fortune** utility is a standard UNIX command, though not a part of POSIX.\n\nThis version tries to follow the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide for [Python](https://www.python.org/) code.\n\n## PORTABILITY\nTested OK under Windows.\n\n## HISTORY\nThe **fortune** utility first appeared in Version 7 AT\u0026T UNIX.\n\nThe much more sophisticated BSD version which this version re-implement was written by Ken Arnold around the end of 1978 and released with 4BSD and 4.1cBSD between 1980 and 1982.\n\nThis re-implementation was made for the [PNU project](https://github.com/HubTou/PNU).\n\nIt also has the *-c* and *-n* options of the Linux version.\nAnd it added *-C* and *-t* options of its own.\n\n## LICENSE\nThis utility is available under the [3-clause BSD license](https://opensource.org/licenses/BSD-3-Clause).\n\n## AUTHORS\n[Hubert Tournier](https://github.com/HubTou)\n\nThe man page is derived from the [FreeBSD project's one](https://www.freebsd.org/cgi/man.cgi?query=fortune\u0026manpath=FreeBSD+14.0-current).\n\n## CAVEATS\nThere are some display differences with the *-f* option between this re-implementation and classical BSD or Linux versions.\nFor instance, probability percentages are printed for all files, not just those indicated.\n\nAnother difference is that this re-implementation does not risk permanently searching for a short or long fortune in a data file which has none. It will make the specified number of attempts, then exit with an error code if nothing was found.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHubTou%2Ffortune","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHubTou%2Ffortune","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHubTou%2Ffortune/lists"}