zoukankan      html  css  js  c++  java
  • Linux/Unix 桌面趣事:文字模式下的 ASCII 艺术与注释绘画

    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 "
    	Vivek Gite
    	vivek@nixcraft.com
    	www.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命令:

  • 相关阅读:
    VMware下安装Ubuntu虚拟机
    py3+urllib+bs4+反爬,20+行代码教你爬取豆瓣妹子图
    老铁,这年头得玩玩这个:Git基本操作【github】
    本地Git与GitHub服务器建立连接(SSH方式通信)
    python开启httpserver服务在自动化测试中的一个小运用
    python测试webservice接口
    Xcache3.2.0不支持php7.0.11
    Nginx设置alias别名目录访问phpmyadmin
    CentOS 7.2.1511编译安装Nginx1.10.1+MySQL5.7.15+PHP7.0.11
    CentOS平滑更新nginx版本
  • 原文地址:https://www.cnblogs.com/k1two2/p/5545822.html
Copyright © 2011-2022 走看看