Linux/Unix 桌面趣事:文字模式下的 ASCII 艺术与注释绘画

简介: boxes 命令不仅是一个文本过滤器,同时是一个很少人知道的有趣工具,它可以在输入的文本或者代码周围框上各种ASCII 艺术画。你可以用它快速创建邮件签名,或者在各种编程语言中留下评论块。这个命令可以在 vim 文本编辑器中使用,但是也可以在各种支持过滤器的文本编辑器中使用,同时也可以在命令行中单独使用。

boxes 命令不仅是一个文本过滤器,同时是一个很少人知道的有趣工具,它可以在输入的文本或者代码周围框上各种ASCII 艺术画。你可以用它快速创建邮件签名,或者在各种编程语言中留下评论块。这个命令可以在 vim 文本编辑器中使用,但是也可以在各种支持过滤器的文本编辑器中使用,同时也可以在命令行中单独使用。

任务: 安装 boxes

使用 apt-get 命令 在 Debian / Ubuntu Linux 中安装 boxes:

$ sudo apt-get install boxes

输出示例:

 1 Reading package 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 and 6 not upgraded.
 7 Need to get 0 B/59.8 kB of archives.
 8 After this 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 for man-db ...
13 Setting up boxes (1.0.1a-2.3) ...

RHEL / CentOS / Fedora Linux 用户, 使用 yum 命令来安装 boxes,(请先启用 EPEL 软件仓库):

# yum install boxes

输出示例:

 1 Loaded plugins: rhnplugin
 2 Setting up Install Process
 3 Resolving Dependencies
 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 --> Finished Dependency Resolution
 8 Dependencies Resolved
 9 ==========================================================================
10  Package        Arch            Version               Repository     Size
11 ==========================================================================
12 Installing:
13  boxes          x86_64          1.1-8.el6             epel           64 k
14 Transaction Summary
15 ==========================================================================
16 Install       1 Package(s)
17 Total download size: 64 k
18 Installed size: 151 k
19 Is this ok [y/N]: y
20 Downloading Packages:
21 boxes-1.1-8.el6.x86_64.rpm                         |  64 kB     00:00
22 Running rpm_check_debug
23 Running Transaction Test
24 Transaction Test Succeeded
25 Running Transaction
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 用户可以按如下使用:

cd /usr/ports/misc/boxes/ && make install clean

或者,使用 pkg_add 命令来增加包:

# pkg_add -r boxes

在一些给定文本周围画出任何种类的包围框

输入下列命令:

echo "This is a test" | boxes

或者,指定要使用的图案的名字:

echo -e "\n\tVivek Gite\n\tvivek@nixcraft.com\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 43 Available Styles in "/etc/boxes/boxes-config":
 2 -------------------------------------------------
 3 ada-box (Neil Bird ):
 4     ---------------
 5     --           --
 6     --           --
 7     ---------------
 8 ada-cmt (Neil Bird ):
 9     --
10     -- regular Ada
11     -- comments
12     --
13 boy (Joan G. Stark ):
14                     .-"""-.
15                    / .===. \
16                    \/ 6 6 \/
17                    ( \___/ )
18       _________ooo__\_____/______________
19      /                                   \
20     |   joan stark   spunk1111@juno.com   |
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 中使用任何外部命令,比如在这个例子中,插入当前日期和时间,输入:

!!date

或者

:r !date

你需要在 vim 中输入以上命令来读取 date 命令的输出,这将在当前行后面加入日期和时分秒:

Tue Jun 12 00:05:38 IST 2012

你可以用 boxes 命令做到同样的功能。如下创建一个作为示例的 shell 脚本或者c程序:

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

现在输入如下(将光标移到第二行,也就是以“Purpose: ...”开头的行)

3!!boxes

瞧,你就会看到如下的输出 :

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

这个短片将会给你介绍boxes命令:

相关文章
|
5月前
|
缓存 网络协议 Unix
Linux(UNIX)五种网络I/O模型与IO多路复用
Linux(UNIX)五种网络I/O模型与IO多路复用
115 0
|
10月前
|
Unix Linux C语言
计算机操作系统实验一 Unix/Linux编程开发环境
计算机操作系统实验一 Unix/Linux编程开发环境
101 0
|
4月前
|
Unix Shell Linux
在Unix/Linux操作系统中,Shell脚本广泛用于自动化任务
在Unix/Linux操作系统中,Shell脚本广泛用于自动化任务
28 2
|
4月前
|
Unix Shell Linux
在Linux和类Unix系统中,Shell提供了多种命令用于用户和权限管理
在Linux和类Unix系统中,Shell提供了多种命令用于用户和权限管理
36 4
|
2月前
|
Oracle Ubuntu Unix
Unix与Linux区别
Unix: Unix是一个操作系统家族的名称,最早由贝尔实验室(Bell Labs)的肖像电机公司(AT&T)开发。最早的Unix版本是在1969年创建的。 Linux: Linux是由芬兰计算机科学家Linus Torvalds在1991年创建的。它是作为一个免费、开放源代码的Unix克隆而开始的。
20 1
|
3月前
|
Unix Shell Linux
在Unix/Linux Shell中,管道(`|`)和重定向
在Unix/Linux Shell中,管道(`|`)和重定向
25 1
|
8月前
|
Unix 大数据 Linux
【Linux is not Unix】Linux前言
【Linux is not Unix】Linux前言
|
4月前
|
Ubuntu Unix Linux
Unix/Linux操作系统的最强入门科普(经典)
Unix/Linux操作系统的最强入门科普(经典)
101 0
|
4月前
|
网络协议 Unix Linux
在Unix/Linux shell中,与网络相关的命令
在Unix/Linux shell中,与网络相关的命令
25 2