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
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:
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)
Want to run it in screensaver mode? Try:
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"
It is easy to show help on screen:
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:
🐧 5 comments so far... add one ↓
|Category||List of Unix and Linux commands|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|