Linux/Unix 案頭趣事:終端上的聖誕樹

來源:互聯網
上載者:User

Linux/Unix 案頭趣事:終端上的聖誕樹

給你的Linux或Unix控制台創造一棵聖誕樹玩玩吧。在此之前,需要先安裝一個Perl模組,命名為Acme::POE::Tree。這是一棵很喜慶的聖誕樹,我已經在Linux、OSX和類Unix系統上驗證過了。

 

安裝 Acme::POE::Tree

安裝perl模組最簡單的辦法就是使用CPAN(Perl綜合典藏網(Comprehensive Perl Archive Network))。開啟終端,把下面的指令敲進去便可安裝Acme::POE::Tree。

  1. ### 以root身份運行 ###
  2. perl -MCPAN -e 'install Acme::POE::Tree'

樣本輸出:

  1. Installing/home/vivek/perl5/man/man3/POE::NFA.3pm
  2. Installing/home/vivek/perl5/man/man3/POE::Kernel.3pm
  3. Installing/home/vivek/perl5/man/man3/POE::Loop.3pm
  4. Installing/home/vivek/perl5/man/man3/POE::Resource.3pm
  5. Installing/home/vivek/perl5/man/man3/POE::Filter::Map.3pm
  6. Installing/home/vivek/perl5/man/man3/POE::Resource::SIDs.3pm
  7. Installing/home/vivek/perl5/man/man3/POE::Loop::IO_Poll.3pm
  8. Installing/home/vivek/perl5/man/man3/POE::Pipe::TwoWay.3pm
  9. Appending installation info to /home/vivek/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/perllocal.pod
  10. RCAPUTO/POE-1.367.tar.gz
  11. /usr/bin/make install -- OK
  12. RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  13. Has already been unwrapped into directory /home/vivek/.cpan/build/Acme-POE-Tree-1.022-uhlZUz
  14. RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  15. Has already been prepared
  16. Runningmakefor R/RC/RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  17. cp lib/Acme/POE/Tree.pm blib/lib/Acme/POE/Tree.pm
  18. Manifying1 pod document
  19. RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  20. /usr/bin/make-- OK
  21. Runningmaketest
  22. 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
  23. t/01_basic.t .. ok
  24. All tests successful.
  25. Files=1, Tests=2, 6 wallclock secs ( 0.09 usr 0.03 sys + 0.53 cusr 0.06 csys = 0.71 CPU)
  26. Result: PASS
  27. RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  28. Tests succeeded but one dependency not OK (Curses)
  29. RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  30. [dependencies] -- NA

 

在Shell中顯示聖誕樹

只需要在終端上運行以下命令:

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

樣本輸出

Gif 01: An animated christmas tree in Perl

Gif 01: 一棵用Perl寫的喜慶聖誕樹

 

樹的定製

以下是我的指令檔tree.pl的內容:

  1. #!/usr/bin/perl
  2. useAcme::POE::Tree;
  3. my $tree =Acme::POE::Tree->new(
  4. {
  5. star_delay =>1.5,# shimmer star every 1.5 sec
  6. light_delay =>2,# twinkle lights every 2 sec
  7. run_for =>10,# automatically exit after 10 sec
  8. }
  9. );
  10. $tree->run();

這樣就可以通過修改stardelay、runfor和light_delay參數的值來自訂你的樹了。一棵好玩的終端聖誕樹就此誕生。

via: http://www.cyberciti.biz/open-source/command-line-hacks/linux-unix-desktop-fun-christmas-tree-for-your-terminal/

作者:Vivek Gite 譯者:soooogreen 校對:wxy

本文由 LCTT 原創編譯,Linux中國 榮譽推出

本文永久更新連結地址:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.