Fortune - ArchWiki

# Fortune

This article or section needs expansion.

Reason: Mention other shells such as Zsh (Discuss in Talk:Fortune#)

Fortune is a simple program that displays a pseudorandom message from a database of quotations.

## Configuration

Along with colors, system info and ASCII symbols, Bash can be made to display a piece of ASCII art on login. ASCII images can be found online and pasted into a text file, or generated from scratch. To set the image to display in a terminal on login, use:

    ~/.bashrc

    cat /path/to/text/file

Random poignant, inspirational, silly or snide phrases can be found in 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.

Note:

By default, `fortune` displays quotes and phrases that are rather innocuous. However, the package does contain a set of comments some people will find offensive, located in `/usr/share/fortune/off/`. See the man page (`man fortune`) for more info on these.

To have a random phrase displayed when logging into a terminal, use:

    ~/.bashrc

    command fortune

Tip:

You can use wikiquote-fortuneAUR to generate fortune files from wikiquote pages, using the syntax `wikiquote-fortune X`, where X is the page's name. To use these files, run `$ fortune /path/to/quote`. You can find fortune files made this way on the AUR. For example, fortune-mod-archlinuxAUR contains Arch related quotes.

These two features can be combined, using the program 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)
    --(~))--->

The ASCII images are generated by `.cow` text files located in `/usr/share/cows`, and all themes can be listed with the `cowsay -l`. These files can be edited to the user's liking; custom images can also be created from scratch or found on the net. The easiest way create a custom cow file is to use an existing one as a template. To test the custom file:

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

This can produce some nice eye candy, and the commands used can be more complex. For a specialized example, take a look here. Another example, to use a random cow, random facial expression, and nicely wrap the text of long fortunes:

    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)
    --(~))--->

Note:

For full 256-colored cowsay-like art use ponysay (version 3.0 has 422 ponies). The syntax is the same, meaning `$ ponysay message` to say something and `ponysay -l` for a complete list of ponies. To select a pony to display, run `$ ponysay --pony x "message"`, where x is a pony. To create more ponies use util-say-gitAUR and store them in `~/.local/share/ponysay/ponies` and `~/.local/share/ponysay/ttyponies/` for desktop and TTY, respectively.

## Random Cow with fortune

    $ fortune -c | cowthink -f $(find /usr/share/cows -type f | shuf -n 1)

Categories:

- Eye candy
- Command shells