创建财富文件

Dec*_*ira 6 command-line fortune

如何创建一个Fortunes文件并将其添加到fortuneshell 上的 * 命令中?

*财富 - “控制台命令打印随机的,希望有趣的格言。”

pte*_*227 9

要获得您自己的自定义幸运饼干,首先创建一个文件并添加您想要显示为幸运的文本帽子。
在您的文本编辑器中粘贴您想要显示的文本(字符串),并且在要显示的每个字符串之间必须有一个%

假设我们正在创建一个带有文件名的报价财富 quotes

sudo nano quotes
Run Code Online (Sandbox Code Playgroud)

粘贴您的文本并像这样编辑

Limits exist only in your mind!
%
"Maybe this world is another planet’s hell."
— Aldous Huxley
%
"Choices are the hinges of destiny." —Edwin Markham
%
“Sometimes it’s the smallest decisions that can 
change your life forever." —Keri Russell
%
“We are the creative force of our life, and through our 
own decisions rather than our conditions, if we carefully
learn to do certain things, we can accomplish
those goals.” —Stephen Covey
Run Code Online (Sandbox Code Playgroud)

保存文件并创建一个 dat 文件:

strfile -c % quotes quotes.dat
Run Code Online (Sandbox Code Playgroud)

这会为您的 cookie 文件创建一个 .dat 文件,其中包含标题结构和每组行的文件偏移表。这允许随机访问字符串。

要查看您的财富,请执行以下操作:

fortune quotes
Run Code Online (Sandbox Code Playgroud)

要使您的 cookie 在您简单地键入财富时显示为标准的幸运饼干,请将引号引号.dat添加到/usr/share/games/fortunes/
如果您想从自定义幸运饼干文件中添加或减去任何字符串,您将需要再次运行strfile -c % quotes quotes.dat以创建新的 dat 文件

您还可以将您的财富添加到 bash 中,这样当您打开外壳时,您的自定义财富就会给您带来惊喜。
nano ~/.bashrc并添加fortune /path/to/quote | lolcat 到文件的末尾并保存

现在关闭您的终端并打开一个新终端以查看它的工作


Jan*_*anC 6

这在fortune(6)和(特别是)的联机帮助页中进行了解释strfile(1)

基本上,您创建一个文本文件,其中包含您的“幸运饼干”,由一行分隔,其中包含一个%符号,没有其他内容。每个幸运饼干可以是 1 行或多行(包括空行)。来自默认幸运饼干文件之一的随机示例:

A day for firm decisions!!!!!  Or is it?
%
A few hours grace before the madness begins again.
%
A gift of a flower will soon be made to you.
%
A long-forgotten loved one will appear soon.

Buy the negatives at any price.
%
A tall, dark stranger will have more fun than you.
Run Code Online (Sandbox Code Playgroud)

然后使用该strfile实用程序创建二进制搜索索引(有关其他选项,请参见其联机帮助页)。当您将文本文件和二进制索引文件都放入 中时/usr/share/games/fortunes/,您的新幸运饼干应该可用。