Tmux

Tmux is a terminal multiplexer; it allows you to create several "pseudo terminals" from a single terminal. This is very useful for running multiple programs with a single connection, such as when you're remotely connecting to a machine using Secure Shell (SSH).

Tmux also decouples your programs from the main terminal, protecting them from accidentally disconnecting. You can detach tmux from the current terminal, and all your programs will continue to run safely in the background. Later, you can reattach tmux to the same or a different terminal.

Some of tmux's features include:

  • Fully customizable status bar

  • Multiple window management

  • Splitting window in several panes

  • Automatic layouts

  • Panel synchronization

  • Scriptability, which allows me to create custom tmux sessions for different purposes

 

Get Started with Tmux on WEXAC

Load the Tmux module module load tmux/3.2a and type tmux on your terminal.

This command launches a tmux server, creates a default session (number 0) with a single window, and attaches to it.

image-20240807-115605.png

 

Now that you're connected to tmux, you can run any commands or programs as you normally would.

You can detach from your tmux session by pressing Ctrl+B then D.

You're no longer attached to the session, but your long-running command executes safely in the background.

To reconnect to the server and reattach to the existing tmux session to resume where you left off:

$ tmux attach

 

Basic tmux keybindings

  • Ctrl+B D — Detach from the current session.

  • Ctrl+B % — Split the window into two panes horizontally.

  • Ctrl+B " — Split the window into two panes vertically.

  • Ctrl+B Arrow Key (Left, Right, Up, Down) — Move between panes.

  • Ctrl+B X — Close pane.

  • Ctrl+B C — Create a new window.

  • Ctrl+B N or P — Move to the next or previous window.

  • Ctrl+B 0 (1,2...) — Move to a specific window by number.

  • Ctrl+B : — Enter the command line to type commands. Tab completion is available.

  • Ctrl+B ? — View all keybindings. Press Q to exit.

  • Ctrl+B W — Open a panel to navigate across windows in multiple sessions.