TranslateProject/sources/tech/20211101 Use the Linux cowsay command for a colorful holiday greeting.md
DarkSun 434fc0c6f6 选题[tech]: 20211101 Use the Linux cowsay command for a colorful holiday greeting
sources/tech/20211101 Use the Linux cowsay command for a colorful holiday greeting.md
2021-11-02 05:04:27 +08:00

3.9 KiB

Use the Linux cowsay command for a colorful holiday greeting

Celebrate the Day of the Dead using this fun Linux command-line tool. Pumpkins painted for Day of the Dead

You may have heard of a small program that takes input, such as a message that you type, and outputs a picture of a cow quoting your message. It is called cowsay. It has been written about before here on Opensource.com.

So, to have a little fun with it, I thought I'd use it to celebrate Día de los Muertos (Day of the Dead).

In addition to a cow, there are other images available. When you install cowsay it includes several other images, which the install stores in /user/share/cowsay. You can use the -l argument to get a list.

$ sudo dnf install cowsay
$ cowsay -l

There's actually quite a bit of development activity related to cowsay and similar programs. It is possible to create your own image files or download images others have made. For instance, Charc0al's cowsay file converter is located on GitHub. You can use this tool to convert your own pictures to the special ASCII format file required by cowsay. Depending on your Linux or FreeBSD terminal settings, you may have color support enabled. The cowsay utility can display color images, as well. Charc0al's converter provides many ready-to-go color files.

I chose to use the Beetlejuice file for my celebration. First, I saved the beetlejuice.cow file to /usr/share/cowsay. This directory is owned by root, so you may have to save the file to your home directory first and then copy it. I also needed to give all users read access.

$ sudo cp beetlejuice.cow /usr/share/cowsay
$ sudo chmod o+r /usr/share/cowsay/beetlejuice.cow

It is interesting to notice how the image is generated. The top sets various ASCII color control codes to variables. These variables are then used to draw the image in the traditional ASCII art style. The image is almost full-body and did not fit my terminal height without scrolling off the screen, so I edited the file and removed the last 15 lines to shorten it.

The image is also detected by the cowsay program and appears in the list.

$ cowsay -l
Cow files in /usr/share/cowsay:
beavis.zen beetlejuice blowfish bud-frogs bunny cheese cower default dragon
...

Now, simply run the program and specify the image using the -f option. Don't forget to provide a message.

`$ cowsay -f beetlejuice "Happy Day of the Dead!"`

ASCII display of Beetlejuice via cowsay

Beetlejuice says Happy Day of the Dead  (CC BY-SA 4.0)

The cowsay command is just another way to have some command-line fun with your Linux computer. Experiment with cowsay and ASCII art—get creative.


via: https://opensource.com/article/21/11/linux-cowsay

作者:Alan Formy-Duval 选题:lujun9972 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出