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
cd cbonsai-git/
makepkg -si
Installing cbonsai on Arch linux using AUR

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
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


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"
Linux Desktop Fun: Bonsai tree generator for CLI lovers
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 as follows or use the man command:
cbonsai --help
cbonsai -h
man cbonsai

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:

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

6 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
    export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"
    mkdir ~/bin/
    cp cbonsai ~/bin/
    export PATH=$PATH:$HOME/bin
    cbonsai -l

    4. Profit?!

  • Gu Jan 31, 2021 @ 16:58

    I write a tool for printing ASCII dinosaur like cowsay:

  • 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.

  • ahorn Aug 23, 2022 @ 20:00

    Hi, thanks for the manual on installing cbonsai.

    I want to tell you that scdoc is a further dependency that I needed to install, maybe you want to add this too.

    best regards!

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.