Fortune

提供: ArchWiki
2021年7月25日 (日) 13:15時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (関連記事を追加)
ナビゲーションに移動 検索に移動

関連記事

Fortune は引用句データベースからランダムに痛烈・示唆的・頓馬・皮肉なメッセージを表示するシンプルなプログラムです。fortune コマンドラインユーティリティは、fortune-mod パッケージの一部です。

インストール

fortune-mod または fortune-mod-gitAUR パッケージをインストールしてください。

ヒント:
  • 特定のソースからの引用を提供するメタパッケージは、AUR で "fortune-mod-" というプレフィックスで利用できます。例えば、fortune-mod-archlinuxAUR は Arch 関係の発言集を含んでいます。
  • wikiquote-fortuneAUR を使うことで wikiquote-fortune Xwikiquote のページからフォーチュンファイルを生成することができます。X はページの名前に置き換えてください。フォーチュンファイルを使うには、$ fortune /path/to/quote を実行します。この方法によって作られたフォーチュンファイルを AUR で見つけることができます。

使用方法

ターミナルで以下のコマンドを実行:

$ 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.

インタラクティブシェルを起動したときにランダムな引用句を表示するには、シェルの rc 設定ファイルに fortune コマンドを追加してください:

#!/bin/bash
# ~/.bashrc
fortune

Dash を使用する場合:

#!/bin/dash
# ~/.dashrc
fortune

ターミナルにログインしたときにランダムな引用句を表示するには、シェルのプロファイル設定ファイルに fortune コマンドを追加してください:

#!/bin/mksh
# ~/.profile
fortune
ノート: デフォルトでは、fortune はあまり害のない引用句を表示します [1]。しかしながら、過激と思えるような引用句もパッケージには含まれており、/usr/share/fortune/off/ に入ります。使用したい場合は fortune(6) を参照してください。

Creating custom files

In order to create a custom file, you must first create a file containing the quotes. Between each quote you must add a line containing only the % character. Save this file using whatever name you want, for example myquotes. Then, run strfile myquotes in a terminal, in order to enable random access of the quotes. You can now access the quotes by executing fortune myquotes in a terminal. For this command to work you must be on the same directory as the myquotes and myquotes.dat files. If you want your quotes to be accessible by just running the fortune command, you must move both files into the /usr/share/fortune/ directory. If you want to make any changes to your file, repeat from the start.

Cowsay

デフォルトの牛さんで fortune

cowsay プログラムを使うことで、アスキーアートと引用句を混ぜることができます:

$ cowthink $(fortune)
 ________________________________________ 
( The best cure for insomnia is to get a )
( lot of sleep. -W.C. Fields             )
 ---------------------------------------- 
        o   ^__^
         o  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

fortune の過激な言葉を牛さんに喋らせるには:

$ cowsay $(fortune -o)
 _________________________________ 
< Chastity is its own punishment. >
 --------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ASCII 画像は /usr/share/cows.cow テキストファイルによって生成されます。cowsay -l で全てのテーマを確認できます。ファイルは自由に編集することが可能です。カスタム画像をスクラッチから作成することもできますし、ネットで探した画像を追加することもできます。cow のカスタムファイルを作成する一番簡単な方法は既存のファイルをテンプレートとして使うことです。カスタムファイルをテストするには:

$ cowsay -f /path/to/file $(fortune)

ランダムな牛さんで fortune

$ fortune -c | cowthink -f $(find /usr/share/cows -type f | shuf -n 1)
  ___________________________________________
( (computers) % A language that doesn't )
( affect the way you think about                  )
( programming is not worth knowing.       )
  ------------------------------------------------------
         o      (__)
          o     /oo|
           o   (_"_)*+++++++++*
                    //I#\ \ \ \ \ \ \ \   I \
                   I[I|I | | | | |   I I `
                   I`I ' /  /  /  '  '     I I
                   I I                       I I
                  ~ ~                     ~ ~
                        Scowleton

カスタマイズしたランダムな牛さんで fortune

目の保養になるような ASCII アートを生成するために、コマンドをさらに複雑にすることもできます。スペシャルな例が こちら にあります。

ランダムな牛さん、ランダムな顔、長い fortune テキストの素敵な表示とラッピングを使う場合:

$ 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  
             ,'``.._   ,'``.
            :,--._:)\,:,._,.:
            :`--,''@@@:`...';\        
             `,'@@@@@@@`---'@@`.     
             /@@@@@@@@@@@@@@@@@:
            /@@@@@@@@@@@@@@@@@@@\
          ,'@@@@@@@@@@@@@@@@@@@@@:\.___,-.
         `...,---'``````-..._@@@@|:@@@@@@@\
           (                 )@@@;:@@@@)@@@\  _,-.
            `.              (@@@//@@@@@@@@@@`'@@@@\
             :               `.//@@)@@@@@@)@@@@@,@;
             |`.            _,'/@@@@@@@)@@@@)@,'@,'
             :`.`-..____..=:.-':@@@@@.@@@@@_,@@,'
            ,'\ ``--....-)='    `._,@@\    )@@@'``._
           /@_@`.       (@)      /@@@@@)  ; / \ \`-.'
          (@@@`-:`.     `' ___..'@@_,-'   |/   `.)
           `-. `.`.``-----``--,@@.'
             |/`.\`'        ,',');
                 `         (/  (/
ノート: 上記の例ではカスタム ASCII アートが含まれたからデータベースからロードされたのは牛さんではなく蛙さんでした。

Ponysay

256色の cowsay のようなアートとして ponysay があります (バージョン 3.0 には422体のポニーが収録されています)。構文は同じで、何か喋らせるときは $ ponysay message を使い、ポニーのリストを表示するには ponysay -l を実行します。表示するポニーを選択したいときは、$ ponysay --pony x "message" を実行してください。x はポニーに置き換えてください。もっと多くのポニーを作りたい場合は、util-say-gitAUR を使ってデスクトップと TTY 用にそれぞれ ~/.local/share/ponysay/ponies~/.local/share/ponysay/ttyponies/ に保存してください。

参照