经常使用github的时候可以发现别人的仓库代码help帮助信息或者查看网页源码里面总是有那么好看的字符串构成的图案,但是自己的代码就没有这些修饰显得那么丑陋。那么如何才能够生成高大上的字符串形状呢?答案就是使用有趣的命令行字符串形状工具boxes。

先来看一个例子

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包含在了大部分的linux发型版本中,只需要使用自带的包管理工具安装就可以了。这里以centos为例

yum install boxes -y

boxes是一个简单实用的应用程序,它使用ASCII艺术风格的字符串形状文本把它包围起来。其字符串的形状默认的风格就是源代码的注释风格,这正是大多数情况下大家所需要的,同时它也提供了其他的选项,像什么狗啊,钻石啊,像上面的图就是使用的钻石形状,我们再来个狗的。


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    (
'---------------------------------------'

生成自己的文本图案

是不是很炫酷啊,其实大家也可以设计自己的形状,具体可参考https://boxes.thomasjensen.com/docs, 生成好了之后就把文本贴在自己程序代码里面吧。这里以peek形状结束。


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|
 +----------------------------*/