0

Linux/Unix的桌面乐趣:在你的终端显示圣诞树

Posted by 撒得一地 on 2015年12月23日 in Linux笔记

让我们在Linux或Unix控制台上显示圣诞树,不要太惊讶,这是纯娱乐。首先,你需要安装一个Perl模块,该模块名为Acme::POE::Tree。
这是一个显示动画圣诞树模块。我已经在Linux上,OS X和类unix系统上测试成功了。

安装Acme::POE::Tree

安装任何perl模块的最简单方法是使用cpan(Comprehensive Perl Archive Network)。打开终端应用程序并输入以下命令安装

Acme::POE::Tree:

## run as root ##

perl -MCPAN -e 'install Acme::POE::Tree'

安装过程输出:

Installing /home/vivek/perl5/man/man3/POE::NFA.3pm
Installing /home/vivek/perl5/man/man3/POE::Kernel.3pm
Installing /home/vivek/perl5/man/man3/POE::Loop.3pm
Installing /home/vivek/perl5/man/man3/POE::Resource.3pm
Installing /home/vivek/perl5/man/man3/POE::Filter::Map.3pm
Installing /home/vivek/perl5/man/man3/POE::Resource::SIDs.3pm
Installing /home/vivek/perl5/man/man3/POE::Loop::IO_Poll.3pm
Installing /home/vivek/perl5/man/man3/POE::Pipe::TwoWay.3pm
Appending installation info to /home/vivek/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/perllocal.pod

  RCAPUTO/POE-1.367.tar.gz
  /usr/bin/make install  -- OK
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  Has already been unwrapped into directory /home/vivek/.cpan/build/Acme-POE-Tree-1.022-uhlZUz

  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  Has already been prepared

Running make for R/RC/RCAPUTO/Acme-POE-Tree-1.022.tar.gz

cp lib/Acme/POE/Tree.pm blib/lib/Acme/POE/Tree.pm
Manifying 1 pod document
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  /usr/bin/make -- OK
Running make test

PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t

t/01_basic.t .. ok
All tests successful.

Files=1, Tests=2,  6 wallclock secs ( 0.09 usr  0.03 sys +  0.53 cusr  0.06 csys =  0.71 CPU)

Result: PASS
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
Tests succeeded but one dependency not OK (Curses)
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  [dependencies] -- NA

在shell显示圣诞树

简单地键入以下命令:

perl -MAcme::POE::Tree -e 'Acme::POE::Tree->new()->run()'

此时屏幕输出:
在Perl中的动画圣诞树

这里是my tree.pl脚本:

#!/usr/bin/perl
use Acme::POE::Tree;
my $tree = Acme::POE::Tree->new(
{
  star_delay => 1.5,  # shimmer star every 1.5 sec
  light_delay => 2,   # twinkle lights every 2 sec
  run_for => 10,  # automatically exit after 10 sec
}
);
$tree->run();

现在你可以通过修改star_delay(闪烁延迟时间),run_for(运行时长),和light_delay(闪烁持续时间)参数来设置你的圣诞树。还有,在你的shell里面出现了一棵圣诞树,是不是非常有趣?

英文原文地址:http://www.cyberciti.biz/open-source/command-line-hacks/linux-unix-desktop-fun-christmas-tree-for-your-terminal/

本文地址:http://coderschool.cn/1367.html

转载请注明英文原文和本文地址

标签:

上一篇:

下一篇:

相关推荐

发表评论

电子邮件地址不会被公开。 必填项已用*标注

6 + 4 = ?

网站地图|XML地图

Copyright © 2015-2024 技术拉近你我! All rights reserved.
闽ICP备15015576号-1 版权所有©psz.