boxes 命令不仅是一个文本过滤器,同时是一个很少人知道的有趣工具,它可以在输入的文本或者代码周围框上各种ASCII 艺术画。你可以用它快速创建邮件签名,或者在各种编程语言中留下评论块。这个命令可以在 vim 文本编辑器中使用,但是也可以在各种支持过滤器的文本编辑器中使用,同时也可以在命令行中单独使用。
任务: 安装 boxes
使用 apt-get 命令[1] 在 Debian / Ubuntu Linux 中安装 boxes:
  1. $ sudoapt-get install boxes
输出示例:
  1. Readingpackage lists...Done
  2. Building dependency tree
  3. Reading state information...Done
  4. The following NEW packages will be installed:
  5.  boxes
  6. 0 upgraded,1 newly installed,0 to remove and6not upgraded.
  7. Need to get0 B/59.8 kB of archives.
  8. Afterthis operation,205 kB of additional disk space will be used.
  9. Selecting previously deselected package boxes.
  10. (Reading database ...224284 files and directories currently installed.)
  11. Unpacking boxes (from.../boxes_1.0.1a-2.3_amd64.deb)...
  12. Processing triggers forman-db ...
  13. Setting up boxes (1.0.1a-2.3)...
RHEL / CentOS / Fedora Linux 用户, 使用 yum 命令来安装[2] boxes,(请先启用 EPEL 软件仓库[3]):
  1. #yum install boxes
输出示例:
  1. Loaded plugins: rhnplugin
  2. Setting up InstallProcess
  3. ResolvingDependencies
  4. There are unfinished transactions remaining.You might consider running yum-complete-transaction first to finish them.
  5. -->Running transaction check
  6. --->Package boxes.x86_64 0:1.1-8.el6 will be installed
  7. -->FinishedDependencyResolution
  8. DependenciesResolved
  9. ==========================================================================
  10. PackageArchVersionRepositorySize
  11. ==========================================================================
  12. Installing:
  13. boxes          x86_64          1.1-8.el6             epel           64 k
  14. TransactionSummary
  15. ==========================================================================
  16. Install1Package(s)
  17. Total download size:64 k
  18. Installedsize:151 k
  19. Isthis ok [y/N]: y
  20. DownloadingPackages:
  21. boxes-1.1-8.el6.x86_64.rpm                         |64 kB     00:00
  22. Running rpm_check_debug
  23. RunningTransactionTest
  24. TransactionTestSucceeded
  25. RunningTransaction
  26. Installing: boxes-1.1-8.el6.x86_64                                 1/1
  27. Installed:
  28.  boxes.x86_64 0:1.1-8.el6
  29. Complete!
FreeBSD 用户可以按如下使用:
  1. cd/usr/ports/misc/boxes/&&make install clean
或者,使用 pkg_add 命令来增加包:
  1. # pkg_add -r boxes
在一些给定文本周围画出任何种类的包围框
输入下列命令:
  1. echo"This is a test"| boxes
或者,指定要使用的图案的名字:
  1. echo-e "\n\tVivek Gite\n\[email protected]\n\twww.cyberciti.biz"| boxes -d dog
输出示例 :
Unix / Linux: Boxes Command To Draw Various Designs
*图01: Unix / Linux: Boxes 命令来画出各式各样的图案 *
怎么样输出所有的图案
语法如下:
  1. boxes option
  2. pipe | boxes options
  3. echo"text"| boxes -d foo
  4. boxes -l
-d 选项用来设置要使用的图案的名字。语法如下:
  1. echo"Text"| boxes -d design
  2. pipe | boxes -d desig
-l 选项列出所有图案。它显示了在配置文件中的所有的框线设计图,同时也显示关于其创作者的信息。
  1. boxes -l
  2. boxes -l |more
  3. boxes -l |less
输出示例:
  1. 43AvailableStylesin"/etc/boxes/boxes-config":
  2. -------------------------------------------------
  3. ada-box (NeilBird):
  4. ---------------
  5. ----
  6. ----
  7. ---------------
  8. ada-cmt (NeilBird):
  9. --
  10. -- regular Ada
  11. -- comments
  12. --
  13. boy (Joan G.Stark):
  14. .-"""-.
  15.                   / .===. \
  16.                   \/ 6 6 \/
  17.                   ( \___/ )
  18.      _________ooo__\_____/______________
  19.     /                                   \
  20.    |   joan stark   [email protected]   |
  21.    |     VISIT MY ASCII ART GALLERY:     |
  22.    | http://www.geocities.com/SoHo/7373/ |
  23.     \_______________________ooo_________/  jgs
  24.                    |  |  |
  25.                    |_ | _|
  26.                    |  |  |
  27.                    |__|__|
  28.                    /-'Y'-\
  29.                   (__/ \__)
  30. ....
  31. ...
  32. output truncated
  33. ..
在使用 vi/vim 文本编辑器时如何通过 boxes 过滤文本?
你可以在 vi 或 vim 中使用任何外部命令,比如在这个例子中,插入当前日期和时间[4],输入:
  1. !!date
或者
  1. :r !date
你需要在 vim 中输入以上命令来读取 date 命令的输出,这将在当前行后面加入日期和时分秒:
  1. TueJun1200:05:38 IST 2012
你可以用 boxes 命令做到同样的功能。如下创建一个作为示例的 shell 脚本或者c程序:
  1. #!/bin/bash
  2. Purpose:Backup mysql database to remote server.
  3. Author:VivekGite
  4. Last updated on:TueJun,122012
现在输入如下(将光标移到第二行,也就是以“Purpose: ...”开头的行)
  1. 3!!boxes
瞧,你就会看到如下的输出 :
  1. #!/bin/bash
  2. /****************************************************/
  3. /* Purpose: Backup mysql database to remote server. */
  4. /* Author: Vivek Gite           */
  5. /* Last updated on: Tue Jun, 12 2012                */
  6. /****************************************************/
这个短片将会给你介绍boxes命令:
此处应有视频,地址: https://dn-linuxcn.qbox.me/static/video/Text%20mode%20box%20and%20comment%20drawing%20filter%20for%20vim%20_%20_nix%20command%20line-glzXjNvrYOc.mp4
参见
  • boxes 帮助手册

作者:Vivek Gite 译者:zky001[5] 校对:wxy[6]
本文由 LCTT[7] 原创编译,Linux中国[8] 荣誉推出

推荐文章
点击标题或输入文章 ID 直达该文章
将文章分享给朋友是对我们最好的赞赏!
继续阅读
阅读原文