Linux / Unix Desktop Fun: Christmas Tree For Your Terminal

in Categories Command Line Hacks last updated December 25, 2017

Let us create Linux or Unix console Christmas tree just for fun and profit. First, you need to install a Perl module called Acme::POE::Tree. It is an animated Christmas tree module. I’ve tested this on Linux, OS X and Unix-like system.

I tested following instructions on a Debian/Ubuntu Linux 17.10 and CentOS Linux 7.x and macOS Unix.

Install Perl curses lib

Type the following apt-get command/apt command to install lib on a Debian/Ubuntu Linux:
$ sudo apt install libcurses-perl libcurses-ui-perl libcurses-widgets-perl
If you are using a CentOS/RHEL Linux (first turn on EPEL repo on a RHEL/CentOS 7 or turn on EPEL repo on a RHEL/CentOS 6 as described here), using yum command:
$ sudo yum install perl-Curses perl-Curses-UI perl-CPAN perl-POE
If you are using a Fedora Linux, type the following dnf command:
$ sudo dnf install perl-Curses perl-Curses-UI perl-CPAN perl-POE

Install compilers and build tools on Linux

See the following docs:

Install Acme::POE::Tree

The easiest way to install any perl module is to use the cpan (Comprehensive Perl Archive Network). Open the terminal application and type the following command to install Acme::POE::Tree:

## run as root ##
perl -MCPAN -e 'install Acme::POE::Tree'

Sample outputs:

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
  /usr/bin/make install  -- OK
  Has already been unwrapped into directory /home/vivek/.cpan/build/Acme-POE-Tree-1.022-uhlZUz
  Has already been prepared
Running make for R/RC/RCAPUTO/Acme-POE-Tree-1.022.tar.gz
cp lib/Acme/POE/ blib/lib/Acme/POE/
Manifying 1 pod document
  /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
Tests succeeded but one dependency not OK (Curses)
  [dependencies] -- NA

Show Christmas tree in the shell

Simply type the following command:

## perl one liner to show Xmas tree ##
perl -MAcme::POE::Tree -e 'Acme::POE::Tree->new()->run()'

Sample outputs:

Gif 01: An animated christmas tree in Perl
Gif 01: An animated christmas tree in Perl

Tree customization

Here is my

# Use cpan module that we installed                
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

Now can play with your tree modifying star_delay, run_for, and light_delay. And ,there you have it a a Christmas tree in your shell for fun.

Not a fan of Perl? Try BASHTree

You can create animated Christmas tree in bash shell running on a Linux, macOS, *BSD, and Unix-like system. Use the wget command to grab the source code:
$ wget
Run it as follows:
$ bash
Sample outputs:

Gif.02: An animated Christmas tree in Bash for Linux/Unix/macOS desktop
Gif.02: An animated Christmas tree in Bash for Linux/Unix/macOS desktop

If you enjoyed this desktop fun app, you may also like to use the following apps on Linux:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 9 comments/add one below):

9 comment

  1. Hi,
    thx for the script but I have an error on Manjaro:

    Test Summary Report
    t/01_basic.t (Wstat: 7424 Tests: 1 Failed: 1)
    Failed test: 1
    Non-zero exit status: 29
    Parse errors: Bad plan. You planned 2 tests but ran 1.
    Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.02 cusr 0.00 csys = 0.04 CPU)
    Result: FAIL
    Failed 1/1 test programs. 1/1 subtests failed.
    Makefile:852 : la recette pour la cible « test_dynamic » a échouée
    make: *** [test_dynamic] Erreur 29
    /usr/bin/make test — NOT OK
    //hint// to see the cpan-testers results for installing this module, try:
    reports RCAPUTO/Acme-POE-Tree-1.022.tar.gz

    1. I got them same error worked after run

      `sudo perl -MCPAN -e ‘install POE’ `

      and then

      `sudo perl -MCPAN -e ‘install Acme::POE::Tree’`

      merry christmas :D

  2. Just a tip for those wanting to run on Fedora: I had to install perl-Curses for this to work for me.

  3. After Gif 01, I think you meant to say “Tree customization” instead of “Teee customization”. Nice cristmass tutorial though :-)

Comments are closed.