tezvyn:

Terminal User Interfaces (TUIs): GUIs for the Console

AI-drafted, machine-checkedSource: github.comintermediate
Terminal User Interfaces (TUIs): GUIs for the Console

A TUI is a graphical interface built from text, offering rich interactivity without leaving the console. Use them for system monitoring (btop), file management, or database clients. The footgun: don't confuse them with CLIs; TUIs are stateful apps.

WHY IT EXISTS Simple command-line interfaces (CLIs) are powerful for scripting but clumsy for tasks requiring constant visual context, like monitoring a server or navigating a complex directory. TUIs were created to provide a richer, interactive experience directly in the terminal, blending the speed and low resource usage of the console with the usability of a graphical interface.

THE MENTAL MODEL Think of a TUI as a GUI for your terminal. It's an application that takes over the terminal screen, drawing its own interface using text characters, colors, and block elements. Unlike a desktop app, it needs no separate window manager or graphics server. It's a self-contained, stateful application living entirely within your terminal session.

HOW IT WORKS TUIs are built with libraries (like Bubble Tea in Go or tui-rs in Rust) that abstract away raw terminal control codes. These libraries let developers position the cursor, set colors, draw boxes, and listen for keyboard or mouse events. The application runs in a continuous loop, redrawing the screen in response to user input or background data changes, creating the illusion of a dynamic interface.

WHEN TO USE IT Use a TUI for tools that benefit from a persistent visual context and keyboard-centric navigation, especially over SSH. They are ideal for system resource monitors (btop), interactive database clients, Git clients (lazygit), and container management dashboards (k9s). They are fast, lightweight, and work well in low-bandwidth environments.

WHEN NOT TO USE IT Avoid TUIs for tasks that are easily scriptable or fit into a standard Unix pipeline (like grep or sed). If your application needs complex graphics, rich media, or is intended for non-technical users who are unfamiliar with terminals, a native GUI or web interface is a much better choice.

ONE CANONICAL EXAMPLE btop++ is a modern resource monitor that perfectly exemplifies a TUI. It displays CPU, memory, disk, and network usage in real-time using graphs, meters, and sortable process lists. It is fully interactive, supporting keyboard and mouse input to change views, filter processes, and send signals, providing an experience comparable to a graphical activity monitor.

Read the original → github.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.