Linux Desktop Fun: Bonsai tree generator for CLI lovers


Bonsai (盆栽) is nothing but planting in a try. It is old age Japanese art of growing small trees in pots. Now you can do that with your Linux or Unix terminal easily for fun and profit. Let us look into the Bonsai tree generator called cbonsai created in Clang and Bash.

Linux Desktop Fun: Bonsai tree generator for CLI lovers

cbonsai is a free and open-source bonsai tree generator, written in C programming language using ncurses. It intelligently creates, colors, and positions a bonsai tree and is entirely configurable via CLI options. It works in static mode. I found live mode interesting. It displays each “step” of growth and pauses a little bit so that the user can watch the tree being grown step by step, just like a real-life Bonsai tree.

Installing cbonsai on Linux

Open the terminal app and run commands as per your Linux distro. For instance, Arch Linux user try an AUR helper such as yay as follows:
yay -S cbonsai-git
However, I cloned the repo and install it as follows:

# AUR not ready? Set up AUR and we need
# packages:
# sudo pacman -S --needed base-devel
git clone https://aur.archlinux.org/cbonsai-git
cd cbonsai-git/
less PKGBUILD
makepkg -si

How to install cbonsai on Debian or Ubuntu Linux

You need to compile source code. Naturally, you need to install GNU GCC Compiler and Development Environment under Debian. If you are using Ubuntu, see how to install GNU GCC Compiler and Development Environment using the apt command:
sudo apt update
sudo apt install build-essential git pkgconf

Make sure you install ncurses Library on a Linux to avoid “fatal error: ncurses.h: No such file or directory” on Linux as follows using the apt-get command:
sudo apt install libncurses6 libncurses-dev ncurses-base ncurses-bin
Now compile and install it:
git clone https://gitlab.com/jallbrit/cbonsai
cd cbonsai
make install PREFIX=~/.local

Here is what we see

cc -Wall -pedantic    cbonsai.c  -lncurses -ltinfo -lpanel  -o cbonsai
install -TDm 0755 cbonsai /home/vivek/.local/bin/cbonsai

How can I install cbonsai on MacOS or *BSD family of operating systems?

The code is portable as coded in C. Compiling on macOS or *BSD is left as an exercise to the readers.

Getting started with our Bonsai tree generator

Type
~/.local/bin/cbonsai
cbonsai

See each step of Bonsai tree growth

Pass the -l or --live option:
cbonsai -l
cbonsai --live

By default, cbonsai waits for 0.03 second in live mode, although we can control TIME in seconds as follows:
cbonsai -l -t 0.06
cbonsai --live --time 0.10

How cool is that? We can seed random number generator too:
cbonsai -l --seed=36677374
cbonsai -l --seed=$(date +%s)

screensaver mode

Want to run it in screensaver mode? Try:
cbonsai --screensaver
cbonsai -S

We can add message next to the tree as follows:
cbonsai -l -m "Welcome to nixCraft LAB"

We can also print tree to terminal when finished by passing the -p option
cbonsai -l -p -m "Welcome to nixCraft LAB"

Getting help

It is easy to show help on screen:
cbonsai --help
cbonsai -h

Summing up

It is a magnificent little fun project for desktop users. You can view source code online on project home page. If you enjoyed this Little desktop fun app, you might also like to use the following apps on Linux or Unix systems:
[toc]linux-unix-desktop-fun[/toc]

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • PHP Fan Boi Jan 31, 2021 @ 10:30

    For macOS on my MacBoo Air (or any Mac for that matter):
    1. Install xcode and homebrew
    2. Then type a few commands:
    brew install pkg-config ncurses
    git clone https://gitlab.com/jallbrit/cbonsai
    export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"
    make
    mkdir ~/bin/
    cp cbonsai ~/bin/
    export PATH=$PATH:$HOME/bin
    cbonsai -l

    3.
    4. Profit?!

  • Gu Jan 31, 2021 @ 16:58

    I write a tool for printing ASCII dinosaur like cowsay: https://github.com/MatteoGuadrini/dinosay

  • z00m Jan 31, 2021 @ 21:24

    Can we install this on FreeBSD? I got FreeNAS server and jail. Please help

  • ftp Jan 31, 2021 @ 22:08

    Useless and time wasting app, yet i installed it. ROFL

  • AlmostEpic Feb 1, 2021 @ 14:16

    The first paragraph mentions doing this for fun and profit? I don’t see how anyone is profiting off of this.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @ webmaster@cyberciti.biz