春江暮客

春江暮客的个人学习分享网站

boxes: An Interesting Command-Line String Shaping Tool

2018-12-21 Miscellaneous
boxes: An Interesting Command-Line String Shaping Tool

When you browse GitHub projects, help output, or even raw source files, you will sometimes notice neatly framed ASCII text blocks used for headings or comments. They do not change the functionality, but they make terminal output and code annotations look much more deliberate.

If you want to generate that style quickly, a simple command-line tool for the job is boxes.

Let’s look at an example first

yum install boxes -y
echo "this is my first command line\n shape text  created by boxes" | boxes -d diamonds -a hcvc

text_shape

boxes is available in many Linux distributions, so in many cases you can install it directly with the system package manager. Here is an example using CentOS:

yum install boxes -y

On Debian or Ubuntu, you can usually try:

apt install boxes -y

boxes is a simple and practical utility that wraps text in ASCII-art-style borders. The default styles are often useful for source-code comments and terminal output, but it also includes more playful options such as dogs, diamonds, and other decorative frames. The example above uses the diamond shape. Here is the dog style:


echo "this is my first command line\n shape text  created by boxes" | boxes -d dog -a hcvc
          __   _,--="=--,_   __
         /  \."    .-.    "./  \
        /  ,/  _   : :   _  \/` \
        \  `| /o\  :_:  /o\ |\__/
         `-'| :="~` _ `~"=: |
            \`     (_)     `/
     .-"-.   \      |      /   .-"-.
.---{     }--|  /,.-'-.,\  |--{     }---.
 )  (_)_)_)  \_/`~-===-~`\_/  (_(_(_)  (
(     this is my first command line     )
 )     shape text  created by boxes    (
'---------------------------------------'

Common Use Cases

This kind of tool is especially useful for:

  • section headers in command-line help output
  • decorative comment blocks at the top of source files
  • stage markers inside shell scripts
  • README snippets that show terminal-style output

Generate your own text patterns

It looks fun, but it is also practical. You can even design your own shapes. For details, see https://boxes.thomasjensen.com/docs. Once you have a style you like, you can paste the generated text directly into your program output or source comments. Here is the peek shape as a final example:


echo "this is my first command line\n shape text  created by boxes" | boxes -d peek -a hcvc
/*       _\|/_
         (o o)
 +----oOO-{_}-OOo--------------+
 |this is my first command line|
 | shape text  created by boxes|
 +----------------------------*/

友情链接

其它