Linux/Unix 桌面趣事:文字模式下的 ASCII 艺术与注释绘画
创始人
2024-03-01 17:05:41
0

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

任务: 安装 boxes

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

$ sudo apt-get install boxes

输出示例:

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 用户, 使用 yum 命令来安装 boxes,(请先启用 EPEL 软件仓库):

# yum install boxes

输出示例:

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 用户可以按如下使用:

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 命令来画出各式各样的图案 *

怎么样输出所有的图案

语法如下:

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

-d 选项用来设置要使用的图案的名字。语法如下:

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

-l 选项列出所有图案。它显示了在配置文件中的所有的框线设计图,同时也显示关于其创作者的信息。

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

输出示例:

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
..

在使用 vi/vim 文本编辑器时如何通过 boxes 过滤文本?

你可以在 vi 或 vim 中使用任何外部命令,比如在这个例子中,插入当前日期和时间,输入:

!!date

或者

:r !date

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

Tue Jun 12 00:05:38 IST 2012

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

#!/bin/bash
Purpose: Backup mysql database to remote server.
Author: Vivek Gite
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命令:

参见

  • boxes 帮助手册

via: http://www.cyberciti.biz/tips/unix-linux-draw-any-kind-of-boxes-around-text-editor.html

作者:Vivek Gite 译者:zky001 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

相关内容

Linux/Unix 桌面...
boxes 命令不仅是一个文本过滤器,同时是一个很少人知道的有趣工...
2024-03-01 17:05:41
Linux/Unix 桌面...
XPenguins 是一个在窗口播放可爱动物动画的程序。默认情况下...
2024-03-01 16:43:01
Linux/Unix 桌面...
给你的Linux或Unix控制台创造一棵圣诞树玩玩吧。在此之前,需...
2024-03-01 16:34:47

热门资讯

Helix:高级 Linux ... 说到 基于终端的文本编辑器,通常 Vim、Emacs 和 Nano 受到了关注。这并不意味着没有其他...
使用 KRAWL 扫描 Kub... 用 KRAWL 脚本来识别 Kubernetes Pod 和容器中的错误。当你使用 Kubernet...
JStock:Linux 上不... 如果你在股票市场做投资,那么你可能非常清楚投资组合管理计划有多重要。管理投资组合的目标是依据你能承受...
Epic 游戏商店现在可在 S... 现在可以在 Steam Deck 上运行 Epic 游戏商店了,几乎无懈可击! 但是,它是非官方的。...
《Apex 英雄》正式可在 S... 《Apex 英雄》现已通过 Steam Deck 验证,这使其成为支持 Linux 的顶级多人游戏之...
从 Yum 更新中排除特定/某... 作为系统更新的一部分,你也许需要在基于 Red Hat 系统中由于应用依赖排除一些软件包。如果是,如...
通过 SaltStack 管理... 我在搜索Puppet的替代品时,偶然间碰到了Salt。我喜欢puppet,但是我又爱上Salt了:)...
如何在 Github 上创建一... 学习如何复刻一个仓库,进行更改,并要求维护人员审查并合并它。你知道如何使用 git 了,你有一个 G...
Opera 浏览器内置的 VP... 昨天我们报道过 Opera 浏览器内置了 VPN 服务,用户打开它可以防止他们的在线活动被窥视。不过...
如何检查你的 Linux 系统... 不知道在使用哪个初始化系统?以下是方法。每个主流 Linux 发行版(包括 Ubuntu、Fedor...