Skip to main content

Linux terminal highlights: Going beyond cowsay

Need to draw attention to something at the command line? Try cowsay, or one of these other terminal tools, to highlight what's important in your scripts.
Image
Cow

Sometimes when you're working at the command line, even the most seasoned sysadmin can see a wall of text and interpret as, well, just a giant wall of text.

It's not that you don't understand what's going on, it's just that there comes a point at which we all suffer from information overload. There's a cognitive limit to how much information we can read and interpret at one time, even when we're familiar with the subject matter and have lots of practice skimming.

When you're working with a GUI, there are all sorts of cues built into the environment that can be used to draw attention to important bits of information. But this comes at a cost. Can you draw attention to information in the terminal?

Of course you can.

Besides capitalization, blinking, surrounding important text in special characters, or adding color, there are a few other options. Specifically, using ASCII art styled blocks in your scripts and outputs to draw your eyes to what matters.

Cowsay

Cowsay is an udderly fantastic utility that takes text and outputs it as the spoken text of an ASCII-art bovine.

You’ll likely find cowsay packaged in your default repositories, and perhaps even already installed. For me, in Fedora, all it took to install was:

$ sudo dnf install cowsay

Then, invoke it with cowsay followed by your message. Perhaps you’d like to pipe in the fortune utility.

$ fortune | cowsay
 _________________________________________
/ If at first you do succeed, try to hide \
\ your astonishment.                      /
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

That’s it! Cowsay ships with few variations, called cow files, that can usually be found in /usr/share/cowsay. To see the cow file options available on your system, use -l flag after cowsay. Then, use the -f flag to try one out.

$ cowsay -f dragon "Run for cover, I feel a sneeze coming on."
 _______________________________________
/ Run for cover, I feel a sneeze coming \
\ on.                                   /
 ---------------------------------------
      \                    / \  //\
       \    |\___/|      /   \//  \\
            /0  0  \__  /    //  | \ \    
           /     /  \/_/    //   |  \  \  
           @_^_@'/   \/_   //    |   \   \ 
           //_^_/     \/_ //     |    \    \
        ( //) |        \///      |     \     \
      ( / /) _|_ /   )  //       |      \     _\
    ( // /) '/,_ _ _/  ( ; -.    |    _ _\.-~        .-~~~^-.
  (( / / )) ,-{        _      `-.|.-~-.           .~         `.
 (( // / ))  '/\      /                 ~-. _ .-~      .-~^-.  \
 (( /// ))      `.   {            }                   /      \  \
  (( / ))     .----~-.\        \-'                 .~         \  `. \^-.
             ///.----..>        \             _ -~             `.  ^-`  ^-_
               ///-._ _ _ _ _ _ _}^ - - - - ~                     ~-- ,.-~
                                                                  /.-~

My real beef with cowsay is that I don’t have enough time today to really milk the cow puns for all they are worth. The steaks are just too high, and I might butcher the joke.

On a more serious note, I had completely forgotten about cowsay until I re-encountered it when learning Ansible playbooks. If you happen to have cowsay installed (and this feature enabled), when you run a playbook, you’ll get your output from a series of cows. For example, running this playbook:

- hosts:
    - localhost
  tasks:
    - action: ping

Might give you the following:

$ ansible-playbook playbook.yml
 __________________
< PLAY [localhost] >
 ------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 ________________________
< TASK [Gathering Facts] >
 ------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [localhost]
 _____________
< TASK [ping] >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [localhost]
 ____________
< PLAY RECAP >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

localhost                  : ok=2    changed=0    unreachable=0    failed=0  

Cowsay is available under a GPLv3 license, and you can find the Perl source code on GitHub. I’ve also seen versions floating around in other languages, so take a look around for other variants; here’s one in R, for example. Implementing your own version in your language of choice might even be a fun programming learning task.

Boxes

Boxes is another useful utility for drawing attention to blocks of data.

On my Fedora machine, boxes wasn't installed by default, but it was in my normal repositories, so installing it was as simple as

$ sudo dnf install boxes

If you're on a different distribution, there's a good chance you'll find it in your default repositories as well.

Boxes a utility I really wish I had in my high school and college computer science courses, where well-intentioned teachers insisted I provide very specific looking comment at the beginning of every source file, function, code block, etc. 

/***************/
/* Hello World */
/***************/

It turns out, once you add a few lines of text inside, formatting them can get, well, tedious. Enter boxes. Boxes is a simple utility for surrounding a block of text with an ASCII art-style box. It comes with defaults for source code commenting, as well as other options.

It's really easy to use. Using pipes, I can push a short greeting into a box (below, a holiday greeting from a previous article I've written about boxes).

$ cat greeting.txt | boxes -d diamonds -a c

Which will give us the output as follows:

       /\          /\          /\
    /\//\\/\    /\//\\/\    /\//\\/\
 /\//\\\///\\/\//\\\///\\/\//\\\///\\/\
//\\\//\/\\///\\\//\/\\///\\\//\/\\///\\
\\//\/                            \/\\//
 \/                                  \/
 /\      I'm wishing you all a       /\
//\\     joyous holiday season      //\\
\\//     and a Happy Gnu Year!      \\//
 \/                                  \/
 /\                                  /\
//\\/\                            /\//\\
\\///\\/\//\\\///\\/\//\\\///\\/\//\\\//
 \/\\///\\\//\/\\///\\\//\/\\///\\\//\/
    \/\\//\/    \/\\//\/    \/\\//\/
       \/          \/          \/

Or perhaps something more fun, like:

echo "I am a dog" | boxes -d dog -a c

Which will, unsurprisingly, give you the following:

          __   _,--="=--,_   __
         /  \."    .-.    "./  \
        /  ,/  _   : :   _  \/` \
        \  `| /o\  :_:  /o\ |\__/
         `-'| :="~` _ `~"=: |
            \`     (_)     `/
     .-"-.   \      |      /   .-"-.
.---{     }--|  /,.-'-.,\  |--{     }---.
 )  (_)_)_)  \_/`~-===-~`\_/  (_(_(_)  (
(              I am a dog               )
 )                                     (
'---------------------------------------'

Boxes comes with lots of options for padding, position, and even processing regular expressions. You can learn more about boxes on the project's homepage, or head over to GitHub to download the source code or contribute your own box.

Figlet

Figlet is a utility for printing text in banner form across your Linux terminal.

You'll likely find figlet packaged in your standard repositories. For me on Fedora, this meant installation was as simple as:

$ sudo dnf install figlet

After that, simply use the program's name to invoke it. You can either use it interactively, or, pipe some text to it, as below: 

$ echo "Hello world" | figlet
 _   _      _ _                            _     _ 
| | | | ___| | | ___   __      _____  _ __| | __| |
| |_| |/ _ \ | |/ _ \  \ \ /\ / / _ \| '__| |/ _` |
|  _  |  __/ | | (_) |  \ V  V / (_) | |  | | (_| |
|_| |_|\___|_|_|\___/    \_/\_/ \___/|_|  |_|\__,_|

There are a number of different font options available for figlet. To see the options available to you, try the command showfigfonts. For me, this displayed over a dozen. I've copied out a few of my favorites below. 

block :                                            

_|        _|                      _|        
_|_|_|    _|    _|_|      _|_|_|  _|  _|    
_|    _|  _|  _|    _|  _|        _|_|      
_|    _|  _|  _|    _|  _|        _|  _|    
_|_|_|    _|    _|_|      _|_|_|  _|    _|  

bubble :

  _   _   _   _   _   _  
 / \ / \ / \ / \ / \ / \ 
( b | u | b | b | l | e )
 \_/ \_/ \_/ \_/ \_/ \_/ 

lean :                     

    _/                               
   _/    _/_/      _/_/_/  _/_/_/    
  _/  _/_/_/_/  _/    _/  _/    _/   
 _/  _/        _/    _/  _/    _/    
_/    _/_/_/    _/_/_/  _/    _/  

script :

               o          
 ,   __   ,_        _ _|_ 
/ \_/    /  |  |  |/ \_|  
 \/ \___/   |_/|_/|__/ |_/
                 /|       
                 \|      

You can find out more about figlet on the project's homepage. The version I downloaded was made available as open source under an MIT license.

You'll find that figlet isn't the only banner-printer available for the Linux terminal. Another option that you may choose to check out is toilet, which comes with its own set of ASCII-art style printing options.

Author’s photo

Jason Baker

Red Hat Certified System Administrator. Linux desktop enthusiast. Map/geospatial nerd. Raspberry Pi tinkerer. Data analysis and visualization geek. Occasional pythonista. More about me

OUR BEST CONTENT, DELIVERED TO YOUR INBOX