FOSS Linux’s Tmux Cheat Sheet

Tmux (TM) is an acronym that stands for Terminal Multiplexing. It is a free and open-source tool that allows you to open many terminals in a single desktop window by adding more than one terminal window. A “tabbed” interface (without actual tabs) is the result, allowing for tab flipping between windows without using the mouse.

Before diving into the cheat sheet, you must ensure that Tmux is installed on your Linux OS. We shall brush through this article, but if you need a detailed report on how to install and use Tmux on Linux, check this comprehensive article.

Installing Tmux

For this guide, we shall be using Ubuntu 20.04LTS. Therefore, if you are using the same operating system as we are, don’t shy off from running the commands provided as they have been tried and tested.

Run the line of code below to install Tmux

sudo apt-get install tmux
tmux
Tmux

Launch Tmux

Once Tmux has been successfully installed on your Linux machine, then proceed and launch it using the command line below:

tmux
start tmux
Start Tmux

When you execute the command above, the apparent result is that Tmux will launch a new shell with a status bar at the bottom. Now that Tmux is up and running let us look at its triggers and commands.

The Tmux commands and triggers

The Tmux trigger is the Ctrl+B keyboard shortcut. When you press it, it tells Tmux to “listen” for the following key combination in a Tmux session. As a result, Ctrl+B is prefixed to all Tmux shortcuts.

Additionally, you may run Tmux commands by name from the command line. Ctrl+B followed by “:” can be used to enter the command line to create a new window. To open a new window, type a new window and hit Enter. This is precisely the same as hitting Ctrl+B and C simultaneously.

Simplified FOSSLinux’s Tmux Cheat Sheet

Tmux Windows commands

FunctionCommand
This command will initiate a new session with the name "fosssession" and window "fosstuts."tmux new -s fosssession-n fosstuts
Create a new windowCtrl + b c
Rename current windowCtrl + b ,
Close current windowCtrl + b &
Previous windowCtrl + b p
Move to the next windowCtrl + b n
Switch/select the window by the numberCtrl + b 0 ... 9
Toggle the last active windowCtrl + b l
Reorder window: swap-window -s 2 -t 1
Move the current window to the left by one position: swap-window -t -1

Tmux Sessions commands

FunctionCommand
Start a new sessiontmux
tmux new
tmux new-session
: new
Start a new session with the name fosssessiontmux new -s fosssession
: new -s fosssession
Attach to the last sessiontmux a
tmux at
tmux attach
tmux attach-session
Show all sessionstmux ls
tmux list-sessions
Ctrl + b s
kill/delete session fosssessiontmux kill-ses -t fosssession
tmux kill-session -t fosssession
kill/delete all sessions except the current onetmux kill-session -a
kill/delete all sessions except fosssessiontmux kill-session -a -t fosssession
Rename sessionCtrl + b $
Detach from sessionCtrl + b d
Detach others during the sessionattach -d
Session and Window PreviewCtrl + b w
Move to the previous sessionCtrl + b (
Move to the next sessionCtrl + b )

Tmux Panes commands

FunctionCommand
Show pane numbersCtrl + b q
Switch/select pane by numberCtrl + b q 0 ... 9
Toggle pane zoomCtrl + b z
Convert pane into a windowCtrl + b !
Resize current pane height (it is optional to hold the second key)Ctrl + b + Up Arrow
Ctrl + b Ctrl + Down Arrow
Ctrl + b + Down Arrow
Ctrl + b Ctrl + Up Arrow
Toggle the last active paneCtrl + b ;
Split pane with horizontal layoutCtrl + b %
Toggle between pane layoutsCtrl + b Spacebar
Split pane with vertical layoutCtrl + b "
Move the current pane leftCtrl + b {
Switch to the next paneCtrl + b o
Move the current pane rightCtrl + b }
Switch to pane to the directionCtrl + b Up Arrow
Ctrl + b Down Arrow
Ctrl + b Right Arrow
Ctrl + b Left Arrow
Toggle synchronize-panes (send command to all panes): setw synchronize-panes
Resize current pane width (it is optional to hold the second key)Ctrl + b + Right Arrow
Ctrl + b Ctrl + Right Arrow
Ctrl + b + Left Arrow
Ctrl + b Ctrl + Left Arrow
Horizontal divides that are evenCtrl+B Alt+1
Vertical divides that are evenCtrl+B Alt+2
Horizontal span for the primary pane, vertical divides for the secondary panesCtrl+B Alt+3
Vertical span for the primary pane, horizontal divides for the secondary panesCtrl+B Alt+3
Layout in tilesCtrl+B Alt+5
Close current paneCtrl + b x

Tmux Help commands

FunctionCommand
List key bindings(shortcuts)tmux list-keys
: list-keys
Ctrl + b ?
Show every session, window, and panetmux info

Tmux Search/Copy Mode commands

FunctionCommand
Use vi keys in the buffer: setw -g mode-keys vi
Enter copy modeCtrl + b [
Switch to copy mode and go one-page higherCtrl + b PgUp
Quit modeq
Go to the top lineg
Go to the bottom lineG
Scroll upArrow Up
Scroll downArrow Down
Move cursor lefth
Move cursor downj
Move cursor upk
Move cursor rightl
Navigate the cursor one word at a time.w
One word at a time, go backwards with the cursorb
Search forward/
Search backward?
Next keyword occurrencen
Previous keyword occurrenceN
Start selectionSpacebar
Clear selectionEsc
Copy selectionEnter
Paste contents of buffer_0Ctrl + b ]
display buffer_0 contents: show-buffer
copy whole visible contents of the pane to a buffer: capture-pane
Show all buffers: list-buffers
Show all buffers and paste selected: choose-buffer
Save buffer contents to buf.txt: save-buffer buf.txt
delete buffer_1: delete-buffer -b 1

Tmux Misc commands

FunctionCommand
Enter command modeCtrl + b :
Set OPTION for all sessions: set -g OPTION
Set OPTION for all windows: setw -g OPTION
Enable mouse mode: set mouse on

Conclusion

Ctrl+B is a simple shortcut for launching Tmux, but the following keys can be a bit more challenging. By typing Ctrl+B followed by “?”, you may access all of Tmux’s keyboard shortcuts, or you can exit the help screen with the “Q” key. The help screen, on the other hand, has a lot of alternatives that aren’t structured in any way. Tmux has numerous sophisticated capabilities you cannot cram; to help you remember them, we’ve created this FOSSLinux cheatsheet for Tmux.

AD

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

SPONSOR AD
22,858FansLike
452FollowersFollow
16SubscribersSubscribe

More Articles Like This