如何创建一个财富文件并将其添加到shell上的fortune*命令中?
*财富-“控制台命令打印随机,希望有趣,格言。”
发布于 2011-04-23 00:46:00
在fortune(6)和(特别是) strfile(1)的手册中解释了这一点。
基本上,您创建一个文本文件,其中包含“幸运曲奇”,其中一行包含单个%符号,没有任何其他内容。每个幸运曲奇可以是1行或更多行(包括空行)。来自默认幸运cookie文件之一的随机示例:
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.然后使用strfile实用程序创建二进制搜索索引(请参阅其手册中的额外选项)。当您将文本文件和二进制索引文件同时放入/usr/share/games/fortunes/中时,您的新的幸运cookie应该是可用的。
发布于 2018-04-05 05:19:55
要获得您自己的自定义幸运饼干,首先创建一个文件并添加您希望显示为财富的文本帽子。
在文本编辑器中粘贴要显示的文本(字符串),在要显示的每个字符串之间必须有一个%
假设我们正在创建一个引号--“财富”,使用文件名quotes
sudo nano quotes粘贴到你的文本中,然后像这样编辑
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保存文件并创建一个dat文件:
strfile -c % quotes quotes.dat这将为您的cookie文件创建一个.dat文件,其中包含每组行的头结构和文件偏移表。这允许随机访问字符串。
要想看到你的财富,请:
fortune quotes要使您的cookie显示为一个标准的幸运饼干时,您只需键入财富,添加引号和quotes.dat到/usr/共享/游戏/财富/
如果要从自定义的幸运cookie文件中添加或减去任何字符串,则需要再次运行strfile -c % quotes quotes.dat来创建新的dat文件。
您还可以添加您的财富,以打击,这样,当您打开外壳,您是伟大的,您的定制财富。
执行nano ~/.bashrc并将fortune /path/to/quote | lolcat添加到文件末尾并保存
现在关闭您的终端并打开一个新的终端来查看它的工作情况。
发布于 2011-04-23 00:47:24
fortune命令记录在这里:man fortune。手册页告诉您如何指定自己的财富文件。默认文件位于/usr/share/games/fortunes中(我通过键入locate fortune找到它们。
如果您想永久地添加自定义文件,有几种方法:将其放入/usr/share/games/ fortune,为fortune创建一个别名(help alias),等等。
https://askubuntu.com/questions/36523
复制相似问题