Fortune
ナビゲーションに移動
検索に移動
Fortune は引用句データベースからランダムにメッセージを表示するシンプルなプログラムです。
設定
カラーやシステム情報、ASCII 記号と一緒に、Bash でログイン時に ASCII アートを表示させることができます。ASCII 画像はネット上で見つけてテキストファイルに貼り付けることができ、または自分で作成することも可能です。ログイン時にターミナルに画像を表示するように設定するには、以下を使います:
~/.bashrc
cat /path/to/text/file
心に残る、感動的あるいは阿呆らしい、または皮肉のきいたフレーズは fortune-mod にあります。
$ fortune
It is Texas law that when two trains meet each other at a railroad crossing, each shall come to a full stop, and neither shall proceed until the other has gone.
ターミナルにログインしたときにランダムな引用句を表示するには、以下を使います:
~/.bashrc
command fortune
cowsay プログラムを使うことで、アスキーアートと引用句を混ぜることができます:
command cowsay $(fortune)
The earth is like a tiny grain of sand,
only much, much heavier.
-----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
(user@host)-(10:10 AM Wed Dec 22)
--(~))--->
command cowthink $(fortune)
( The best cure for insomnia is to get a )
( lot of sleep. -W.C. Fields )
----------------------------------------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||
(user@host)-(10:10 AM Wed Dec 22)
--(~))--->
ASCII 画像は /usr/share/cows の .cow テキストファイルによって生成されます。cowsay -l で全てのテーマを確認できます。ファイルは自由に編集することが可能です。カスタム画像をスクラッチから作成することもできますし、ネットで探した画像を追加することもできます。cow のカスタムファイルを作成する一番簡単な方法は既存のファイルをテンプレートとして使うことです。カスタムファイルをテストするには:
$ cowsay -f /path/to/file $(fortune)
これでも多少の目の保養にはなりますが、コマンドをさらに複雑にすることもできます。スペシャルな例が こちら にあります。他の例として、ランダムな牛さん、ランダムな顔、長いフォーチュンのテキストの素敵なラッピングを使う場合:
command fortune -a | fmt -80 -s | $(shuf -n 1 -e cowsay cowthink) -$(shuf -n 1 -e b d g p s t w y) -f $(shuf -n 1 -e $(cowsay -l | tail -n +2)) -n
________________________________________
( Fry: I must be a robot. Why else would )
( human women refuse to date me? )
----------------------------------------
o
o
o
,'``.._ ,'``.
:,--._:)\,:,._,.:
:`--,''@@@:`...';\
`,'@@@@@@@`---'@@`.
/@@@@@@@@@@@@@@@@@:
/@@@@@@@@@@@@@@@@@@@\
,'@@@@@@@@@@@@@@@@@@@@@:\.___,-.
`...,---'``````-..._@@@@|:@@@@@@@\
( )@@@;:@@@@)@@@\ _,-.
`. (@@@//@@@@@@@@@@`'@@@@\
: `.//@@)@@@@@@)@@@@@,@;
|`. _,'/@@@@@@@)@@@@)@,'@,'
:`.`-..____..=:.-':@@@@@.@@@@@_,@@,'
,'\ ``--....-)=' `._,@@\ )@@@'``._
/@_@`. (@) /@@@@@) ; / \ \`-.'
(@@@`-:`. `' ___..'@@_,-' |/ `.)
`-. `.`.``-----``--,@@.'
|/`.\`' ,',');
` (/ (/
(user@host)-(10:10 AM Wed Dec 22)
--(~))--->
fortune でランダムな牛さん
$ fortune -c | cowthink -f $(find /usr/share/cows -type f | shuf -n 1)