How to use Byobu

By Alex2 minutes read

TLDR: A cheatsheet for Byobu keybindings.

Introduction

Byobu offers functionality similar to tmux, enabling users to manage multiple terminals through a single interface. Essentially, it serves as a terminal multiplexer and session manager.

Such a tool proves invaluable when interacting with a server via SSH. Instead of launching a new terminal and establishing a fresh server connection each time you require an additional terminal, you can configure your server to initiate Byobu or tmux at the onset of your session, giving you access to as many terminals as desired. A standout feature of Byobu is its ability to maintain terminal sessions even after detaching from them.

Byobu enhances the terminal experience by leveraging either Screen or tmux, depending on your preference. It provides users with valuable statistics and offers intuitive hotkeys for essential commands.

Installing Byobu

For Ubuntu users:

sudo apt install byobu.

For MacOS users:

brew install byobu

Else take a look at https://www.byobu.org/downloads

Start Byobu

byobu

Configure Ubuntu to run Byobu from the beginning

byobu-config

You’re encouraged to customize settings as per your preferences.

Locate the “Byobu currently launches at login (toggle on)” setting and select it, followed by pressing return.

Afterward, navigate back to the menu and exit byobu-config (move to the exit option using the tab key and press return).

Resume previous sessions

byobu –r session_title

Hotkeys

Byobu has user-friendly keybindings based on the function keys:

Understanding Detaching and Session Maintenance

Here’s a brief demonstration. SSH into another machine. There you launch Byobu and run a command:

byobu
echo hello

Subsequently, press F6 to detach from Byobu. Next, execute: exit.

Upon reconnecting via SSH to your machine, you’ll observe the echo hello command still displayed. The act of detaching doesn’t terminate your session; rather, it grants you entry to another. This means you can initiate a prolonged task, detach, and return later to inspect the results.

Note for vim users

Vim users may notice an odd behavior when employing Ctrl-Left and Ctrl-Right keys jump between words in vim and other applications.

A remedy I’ve found effective is:

echo ':set term=xterm' >> ~/.vim/vimrc
echo 'unbind-key -n C-Left' >> ~/.byobu/keybindings.tmux
echo 'unbind-key -n C-Right' >> ~/.byobu/keybindings.tmux
echo 'set-window-option -g xterm-keys on' >> ~/.byobu/.tmux.conf
echo "set -g terminal-overrides 'xterm*:smcup@:rmcup@'" >> ~/.byobu/.tmux.conf

References

[1] http://www.saltycrane.com/blog/2012/10/how-start-long-running-process-screen-and-detach-it/

[2] http://tmux.sourceforge.net/

[3] https://www.byobu.org/documentation.html

[4] http://www.howtogeek.com/58487/how-to-easily-multitask-in-a-linux-terminal-with-byobu/

[5] http://blog.smartlogicsolutions.com/2010/01/22/ubuntu-byobu-landscape/

[6] https://cheatography.com/mikemikk/cheat-sheets/byobu-keybindings/