Linux / Unix Desktop Fun: Text Mode ASCII-art Box and Comment Drawing

by on June 11, 2012 · 13 comments· LAST UPDATED June 19, 2012

in Linux, Linux desktop

Boxes command is a text filter and a little known tool that can draw any kind of ASCII art box around its input text or code for fun and profit. You can quickly create email signatures, or create regional comments in any programming language. This command was intended to be used with the vim text editor, but can be tied to any text editor which supports filters, as well as from the command line as a standalone tool.

Task: Install boxes

Use the apt-get command to install boxes under Debian / Ubuntu Linux:
$ sudo apt-get install boxes
Sample outputs:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  boxes
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 0 B/59.8 kB of archives.
After this operation, 205 kB of additional disk space will be used.
Selecting previously deselected package boxes.
(Reading database ... 224284 files and directories currently installed.)
Unpacking boxes (from .../boxes_1.0.1a-2.3_amd64.deb) ...
Processing triggers for man-db ...
Setting up boxes (1.0.1a-2.3) ...

RHEL / CentOS / Fedora Linux users, use the yum command to install boxes (first enable EPEL repo as described here):
# yum install boxes
Sample outputs:

Loaded plugins: rhnplugin
Setting up Install Process
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
--> Running transaction check
---> Package boxes.x86_64 0:1.1-8.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================
 Package        Arch            Version               Repository     Size
==========================================================================
Installing:
 boxes          x86_64          1.1-8.el6             epel           64 k
Transaction Summary
==========================================================================
Install       1 Package(s)
Total download size: 64 k
Installed size: 151 k
Is this ok [y/N]: y
Downloading Packages:
boxes-1.1-8.el6.x86_64.rpm                         |  64 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : boxes-1.1-8.el6.x86_64                                 1/1
Installed:
  boxes.x86_64 0:1.1-8.el6
Complete!

FreeBSD user can use the port as follows:
cd /usr/ports/misc/boxes/ && make install clean
Or, add the package using the pkg_add command:
# pkg_add -r boxes

Draw any kind of box around some given text

Type the following command:

echo "This is a test" | boxes

Or specify the name of the design to use:

echo -e "\n\tVivek Gite\n\tvivek@nixcraft.com\n\twww.cyberciti.biz" | boxes -d dog

Sample outputs:

Unix / Linux: Boxes Command To Draw Various Designs

Fig.01: Unix / Linux: Boxes Command To Draw Various Designs

How do I list all designs?

The syntax is:

 
boxes option
pipe | boxes options
echo "text" | boxes -d foo
boxes -l
 

The -d design option sets the name of the design to use. The syntax is:

echo "Text" | boxes -d design
pipe | boxes -d desig

The -l option list designs. It produces a listing of all available box designs in the config file, along with a sample box and information about it's creator:

boxes -l
boxes -l | more
boxes -l | less

Sample outputs:

43 Available Styles in "/etc/boxes/boxes-config":
-------------------------------------------------
ada-box (Neil Bird ):
    ---------------
    --           --
    --           --
    ---------------
ada-cmt (Neil Bird ):
    --
    -- regular Ada
    -- comments
    --
boy (Joan G. Stark ):
                    .-"""-.
                   / .===. \
                   \/ 6 6 \/
                   ( \___/ )
      _________ooo__\_____/______________
     /                                   \
    |   joan stark   spunk1111@juno.com   |
    |     VISIT MY ASCII ART GALLERY:     |
    | http://www.geocities.com/SoHo/7373/ |
     \_______________________ooo_________/  jgs
                    |  |  |
                    |_ | _|
                    |  |  |
                    |__|__|
                    /-'Y'-\
                   (__/ \__)
....
...
output truncated
..

How do I filter text via boxes while using vi/vim text editor?

You can use any external command with vi or vim. In this example, insert current date and time, enter:
!!date
OR
:r !date
You need to type above command in Vim to read the output from the date command. This will insert the date and time after the current line:

Tue Jun 12 00:05:38 IST 2012

You can do the same with boxes command. Create a sample shell script or a c program as follows:

#!/bin/bash
Purpose: Backup mysql database to remote server.
Author: Vivek Gite
Last updated on: Tue Jun, 12 2012

Now type the following (move cursor to the second line i.e. line which starts with "Purpose: ...")

3!!boxes

And voila you will get the output as follows:

#!/bin/bash
/****************************************************/
/* Purpose: Backup mysql database to remote server. */
/* Author: Vivek Gite           */
/* Last updated on: Tue Jun, 12 2012                */
/****************************************************/

This video will give you an introduction to boxes command:

(Video:01: boxes command in action. BTW, this is my first video so go easy on me and let me know what you think.)

See also

  • boxes man page
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!
This entry is 5 of 5 in the Linux / Unix Desktop Fun series. Keep reading the rest of the series:
  1. Terminal ASCII Aquarium
  2. Steam Locomotive
  3. Let it Snow On Your Desktop
  4. Summon Swarms Of Penguins To Waddle About The Desktop
  5. Text Mode Box and Comment Drawing

1 Ryan June 11, 2012 at 8:30 pm

rmalek@moil:~$ cowsay Your boxes are no match for my cow power!

 ____________________________________
/ Your boxes are no match for my cow \
\ power!                             /
 ------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

rmalek@moil:~$

2 William June 12, 2012 at 12:28 am

Great

3 Bhavesh June 12, 2012 at 4:31 am

Nice tool to greet on server login by adding it to Banner.

4 beparas June 12, 2012 at 5:43 am

Hi,
This is very good as well as funny information. :)
Thanks

5 indu June 12, 2012 at 7:11 am

a C comment in a bash script? Happy debugging.

6 Eol June 12, 2012 at 8:06 am

Thak you for sharing with me boxes
but +1 for cowsay – I’ve used that magic cow for a years and next entry is one of first when I bring-up a new machine

grep cow ~/.bashrc
fortune /usr/share/games/fortunes/bg | cowsay -b -f /usr/share/cowsay/cows/tux.cow -n

7 nixCraft June 12, 2012 at 8:50 am

@indu

It was just a demo. Not a real script :P Also, I’m too lazy to create and upload updated video.

@all, yes cowsay rocks, but this tool offer other options too.

Appreciate all comments.

8 beparas June 12, 2012 at 11:41 am

Try this,
$ apt-get install sl
$ LS
after installing ‘sl’ packet, run ‘LS’ command, It display animated train running on your terminal. :)

9 Bruno Braga June 13, 2012 at 1:28 pm
10 BoobLove June 13, 2012 at 9:57 pm

@beparas
Thats funny :)

Thanks for the sample outputs in the articles you write here. Great idea.

11 Manuel June 14, 2012 at 12:21 pm
dir='/usr/share/cows/'
file=`/bin/ls -1 "$dir" | sort --random-sort | head -1`
cow=$(echo "$file" | sed -e "s/\.cow//")
fortune -a | cowsay -f $cow

12 notaname June 21, 2012 at 8:23 pm

Try piping the output of figlet to boxes:

echo “abc” | figlet | boxes

13 Malik Perang December 21, 2012 at 8:22 am

Hello sir.
How to use the command?
can it be used in vim editor?
please i want to know.

Comments on this FAQ are closed. If you'd like to continue the discussion on this topic, you can do so at our forum.

Tagged as: , , , , , , , , , , , , ,

Previous post:

Next post: