Blog
Get Perfectly Good Terminal Multiplexing with Byobu and Flox
Steve Swoyer | 20 December 2024
Fun Package Fridays is a series where we ask members of the Flox team to share fun and perhaps not-so-well-known tools and utilities you can find in the Flox Catalog, powered by Nix. Today's edition comes from staff writer Steve Swoyer, whose been left to his own devices. All of them.
With the sounds of the Tubes’ classic “Talk to Ya Later” blasting in my mind’s ear, I give you the final Fun Package Friday(R)(TM) of 2024. And as the Hangman in the film classic Blazing Saddles puts it, “This one’s a doozy.” Because not only is it the Friday before Christmas, it’s the Friday before I ain't got no job to do for nigh on 10 days before Christmas. So if I’m writing as if I’m the only one left up in here to edit and/or proof my content, it’s because I … almost am.
This week’s fun package is Byobu, a terminal tool you can use to split your screen, run multiple sessions, and reconnect to sessions, even after you disconnect. I’d call it a “terminal multiplexer,” but it isn’t, quite: it’s actually a front-end for multiplexers like tmux or GNU Screen. It stands on the shoulders of giants.
But it's gigantic in its own way.
Read on to discover how Byobu can fit into your workflow!
Perfectly good terminal multiplexing
I first fell in love with Byobu on Ubuntu 10.04 15 years ago. It was the kind of terminal multiplexer I’d always wanted but didn’t even know to ask for. Pretty quickly, it morphed into a pre-configured, easily customizable front-end for tmux, which (circa 2011-2012) I’d resisted playing around with. Then as now, Byobu also supports GNU Screen as its terminal-multiplexing back-end. You can select either using the byobu-select-backend
command.
Byobu ships with a passel of pre-built status notifications, including information about available updates; whether or not a reboot is required; network activity; CPU, disk, and memory usage; number of active users; system load, and so on. It also makes it easy to define custom status notifications, like the current Git branch and its status; GPU usage; or how many Docker containers are running. Basically, if you can construct a shell command that returns information about a resource or service, you can usually turn that into a custom Byobu status notification.
Just as important, Byobu pre-defines shortcut keys that simplify the following operations:
F2
creates a new terminal window;F3
cycles backward through active windows;F4
cycles forward through active windows;F6
detaches from a session but leaves you logged in[1];F7
lets you scroll back through terminal history;F8
renames the current window;F9
launches a configuration menu;SHIFT
+F2
splits the active window into two horizontal panes;CTRL
+F2
splits the active window into two vertical panes;SHIFT
+F3
cycles backward through active panes in a split-window configuration;SHIFT
+F4
cycles forward through active panes in a split-window configuration;
[1] Note: both F6
and SHIFT
+ F6
seem to produce the same result with the default keybindings?
For those of us who came up with GNU Screen, Byobu can also optionally support its default shortcut/escape key sequence, CTRL
+ A
+ <KEY>
. But—good news!—you can turn this on or off. Emacs users will want to turn this the heck off.
Let’s take a look at how it works.
Getting it
First, we’ll install the byobu
package from the Flox catalog, and we’ll grab the tmux
package, too, just in case it isn’t already available on our system. Let’s assume we’re in our default Flox environment, which typically lives in $HOME
.
Next we’ll run flox activate -- byobu
. This tells Flox to run the command byobu
in the subshell it creates when activating the environment. Running byobu
puts us into a multiplexed terminal session:
Using it
I’m an avid Byobu user, so my status notifications are already pre-configured. Across the bottom, from left to right, Byobu displays information about:
- My OS/Linux distribution;
- The version of my OS/Linux distribution (this says
n/a
because I’m running Debian testing); - My CPU architecture
- WiFi signal strength/quality
- System load
- Number of processors (inclusive of threads)
- Total memory/Memory utilization
- My IP address
- Date
- Time
I can configure what gets displayed here using the F9
shortcut key and selecting the Toggle Status Notifications
option. (You can also trigger this wizard from outside of Byobu by running byobu-config
.) This brings up the following ncurses interface:
First I’ll create a vertical split-screen by pressing CTRL
+ F2
. Then I’ll run htop in one pane and iotop in t’other. Just because it’s the Friday before Christmas (and PTO) and I’m feeling a penurious lack of creativity.
From here, I can sub-divide my panes horizontally if I so desire. And I do so desire:
With Glances and Neofetch on top of htop and iotop, I’d say I’m well on my way to information overload. Oh yes: Did I mention that I got each of these packages, too, from the Flox Catalog? Several of them (htop
, iotop
) are already installed in my default
Flox environment. Unlike the older packages I get from the Ubuntu or Debian (stable) catalogs, the ones I get from the Flox Catalog are usually the latest (or at least almost-latest) versions.
Advanced Usage
This isn’t necessarily advanced, but it does give you a slightly better idea of how Byobu can improve your workflow. In the screenshot below, I first activated Flox’s Ollama prototype runtime as a remote environment, using the command flox activate -s -r flox/ollama
.
This created a temporary local copy of the remote Flox environment ollama
, activates it (with the -r
switch, for “remote”), starts the Ollama service (with the -s
switch, for “services”), and puts me into a Flox subshell.
Then I ran the following command:
This lets me monitor the messages generated by Ollama in the active window.
I then used SHIFT
+ F2
to split my window into two horizontal panes, and pressed CTRL
+ A
+ TAB
(I love my GNU Screen shortcuts) to switch to the other, just-created pane. Here I activated another instance of the Flox Ollama prototype environment (flox activate -r /flox/ollama
) and told Ollama to fetch and run the latest version of the llama3
model (ollama run llama3
). Once the model loaded, I was able to query it in the top-most pane of my sub-divided terminal window.
If you're working with a runtime service that prints messages to the console (e.g., Node.js), this split-screen capability can be enormously useful in your workflow.
This has been Fun Package Friday(R)(TM)
So that’s Byobu. Before Tilix, Kitty, or iTerm2 were things, it gave you an easy way to subdivide your terminal window into panes. (Incidentally, you can flox install
each of these terminal emulators from the Flox Catalog!) For my money, it’s still one of the best solutions to this problem, and also lets you detach, persist, and reconnect to your workflows—whether you’re logged in via a local console or connecting via ssh. It’s fairly configurable, boasts optional mouse support, and runs everywhere I’ve tried it. It lives in my default
Flox environment, so it’s one of the first thing that gets installed on a new system.
Happy: Hacking! Christmas! Hannukah! Festivus! Saturnalia!