Zero-dependency Python terminal animations: 3D starfield, matrix rain, block clock.
Terminal animations and widgets in pure Python 3. Each script draws straight into your terminal window with ANSI escape codes (short character sequences that tell a terminal to move the cursor or change colour). There are five full-screen animations, a large clock, a now-playing music widget for macOS, and a set of panes for watching the instruction file a coding agent reads. No dependencies, no install step, and every script runs on its own.
Computer Science and Maths:
- How a terminal draws colour and moves the cursor with ANSI escape codes.
- Perspective projection: dividing by depth so far-away stars cluster in the middle (
animations/starfield.py). - Cellular automata, where each cell's next state depends on its neighbours: Conway's Game of Life (
animations/game_of_life.py) and a fire simulation (animations/fire.py). - Drawing patterns from sine waves (
animations/plasma.py). - An animation loop: draw a frame, wait, draw the next.
- Handling signals (messages the operating system sends a program, such as the one Ctrl-C sends) so a program can tidy up before it exits.
You will need:
- Python 3.
- Git, to download the code.
- A terminal with 24-bit colour and ANSI escape support, such as iTerm2, WezTerm or most Linux terminals.
The animations and the clock were run on macOS with Python 3.12. The now-playing widget is macOS only.
-
Download the code:
git clone https://github.com/godofecht/terminal-eye-candy.git cd terminal-eye-candy -
Run any script:
python3 animations/starfield.py
The animation fills the terminal window. Make the window bigger or smaller and it redraws to fit.
-
Press Ctrl-C to quit. Each script restores the cursor and resets colours on exit, through a signal handler, so a terminal is never left in a broken state.
| Script | What it draws |
|---|---|
animations/starfield.py |
3D starfield with perspective projection |
animations/matrix_rain.py |
Falling glyph columns |
animations/fire.py |
Cellular fire simulation |
animations/plasma.py |
Sine-field plasma |
animations/game_of_life.py |
Conway's Game of Life |
| Script | What it does |
|---|---|
widgets/clock.py |
Block-digit clock |
widgets/nowplaying/nowplaying.py |
Current macOS track, read over AppleScript |
The now-playing widget shows the track playing in Spotify or Apple Music. Open one of them first. Its controls:
| Key | Does |
|---|---|
| Space | play or pause |
| Left arrow | back 5 seconds |
| Right arrow | forward 5 seconds |
| Up arrow | volume up |
| Down arrow | volume down |
| q, Ctrl-C or Ctrl-D | quit |
widgets/nowplaying/ftxui/ holds a C++ version of the now-playing widget, built with FTXUI v5.0.0 via CMake FetchContent. It needs CMake 3.14 or newer and a C++17 compiler. CMake downloads FTXUI for you:
cmake -B build widgets/nowplaying/ftxui && cmake --build build
./build/nowplayingIt uses the same keys, except that q or Esc quits.
A set of panes that watch and edit the instructions given to a coding agent. The agent reads its instructions from a file called CLAUDE.md. The panes are written to sit side by side in a tiled terminal.
| Script | Pane |
|---|---|
meta/prompt_viewer.py |
Live view of CLAUDE.md |
meta/context_window.py |
Context window usage |
meta/prompt_rewriter.py |
Interactive editor for the instructions |
meta/prompt_diff.py |
Every change to CLAUDE.md, as it happens |
meta/editor.py |
Click-to-edit CLAUDE.md |
Split them into panes with WezTerm:
wezterm cli split-pane -- python3 meta/prompt_viewer.pyFour of the panes look for the file at ~/terminal-eye-candy/CLAUDE.md, so clone the repo into your home folder if you want to try them. The repo already has a CLAUDE.md there.
meta/prompt_rewriter.py controls:
| Key | Does |
|---|---|
| a | add a rule, then type it |
| Enter | confirm the rule, then Enter again to save it |
| Esc | cancel |
| x | clear the whole file, with no undo |
| q | quit |
meta/editor.py controls: click a line to put the cursor there, arrow keys, Home and End to move, Enter, Backspace and Delete to edit, Ctrl-S to save and Ctrl-Q to quit.
Every animation follows the same loop. It reads the terminal size, works out the next frame in memory, builds one long string of characters and colour codes, writes it to the screen in one go, then sleeps for a moment. Writing the whole frame at once stops the screen flickering. At start-up each script hides the cursor and registers a cleanup function for the Ctrl-C signal. cleanup resets the colours and shows the cursor again.
| File or folder | What is in it |
|---|---|
animations/ |
The five full-screen animations. matrix_rain.py is the shortest, at 29 lines. |
widgets/clock.py |
The block-digit clock and date. |
widgets/nowplaying/ |
The macOS now-playing widget in Python, and the C++ version in ftxui/. All AppleScript calls live here. |
meta/ |
The five panes that watch and edit CLAUDE.md. |
docs/animations.jpg |
The screenshot at the top of this page. |
- Change the fire colours. Edit the
PALETTElist inanimations/fire.py, which runs from black through red and orange to white. - Change how many stars there are.
NUM_STARSinanimations/starfield.pyis capped at 400. - Change the rules of life. Line 25 of
animations/game_of_life.pysays a live cell survives with 2 or 3 neighbours and a dead cell is born with 3. Try other numbers and see which patterns appear. - Change how full the Game of Life starts.
random.random() > 0.65ininitdecides the starting density. - Write your own animation. Copy
animations/matrix_rain.py, keep itscleanupfunction and signal handlers, and replace the drawing code.
Requires Python 3 and a terminal with 24-bit colour and ANSI escape support. Colour uses 24-bit truecolor where possible, with a 256-colour fallback.
The screenshot was captured by running each script in a pseudo-terminal at 100 by 30 and rendering the final frame. No screen recorder involved.
The starfield projects each star with sx = x / z * cx + cx, where cx is the centre column and z is the star's depth. As z falls, stars move outward and speed up.
meta/context_window.py estimates token counts from file sizes and compares them against a 200,000-token context window. It reads the memory files under ~/.claude and the CLAUDE.md files in ~/.claude and the current folder.
The five animations and the clock were run in a pseudo-terminal on macOS and exited cleanly on Ctrl-C. One rare case: if the terminal stops reading output (for example, while output is paused) and you press Ctrl-C mid-frame, four of the animations can exit with a RuntimeError and leave the cursor hidden. Type reset to fix the terminal if this happens.
The meta panes have the path ~/terminal-eye-candy written into the code. Pressing x in meta/prompt_rewriter.py clears CLAUDE.md at once, with no confirmation.
You can use, copy and change this code for any purpose, as long as you keep the copyright notice. See LICENSE (MIT).
Written by Abhishek Shivakumar. The C++ widget uses FTXUI by Arthur Sonzogni.
