Skip to content

Instantly share code, notes, and snippets.

@bouzou4
Created June 9, 2023 19:11
Show Gist options
  • Save bouzou4/5b94ef6d12adb0269051a774f6bbb589 to your computer and use it in GitHub Desktop.
Save bouzou4/5b94ef6d12adb0269051a774f6bbb589 to your computer and use it in GitHub Desktop.
This cheat sheet provides a quick overview of tmux commands, enabling you to manage terminal sessions effectively and boost your productivity. tmux, short for terminal multiplexer, is a valuable tool for running and managing multiple terminal sessions within a single terminal window or remote shell. This guide covers session management, window m…

tmux Cheatsheet

This cheat sheet provides a quick overview of tmux commands, enabling you to manage terminal sessions effectively and boost your productivity. tmux, short for terminal multiplexer, is a valuable tool for running and managing multiple terminal sessions within a single terminal window or remote shell. This guide covers session management, window management, pane management, and other miscellaneous commands to aid in effective tmux utilization.

Session Management

A tmux session is an independent workspace that houses one or multiple windows. Users or shell scripts create sessions, and each session maintains its state independently. They are useful for organizing terminal activities, especially in remote shell scenarios where a dropped connection can disrupt your work. In such a case, tmux sessions remain alive, and you can reattach to them later.

Action Command
Start new session tmux
Start new named session tmux new -s myname
Attach to last session tmux a or tmux attach
Attach to named session tmux a -t myname
List all sessions tmux ls
Detach from session tmux detach or Ctrl-b d
Kill session tmux kill-session -t myname

Window Management

In tmux, a window functions similarly to a tab in traditional GUI-based terminals. It's essentially a full-size container that can house one or more panes (think of split views within a tab). tmux provides various commands to manage these windows, such as creating new ones, navigating between them, killing them, or renaming them.

Action Command
Create window Ctrl-b c
Go to window Ctrl-b n (next), Ctrl-b p (previous), Ctrl-b l (last), Ctrl-b 0..9 (window by number)
Kill window Ctrl-b &
Rename window Ctrl-b ,
List all windows Ctrl-b l

Pane Management

A pane in tmux is a sub-window that resides within a window. You can split your tmux windows into multiple panes and have multiple shell sessions within the same window. This feature can be especially useful for monitoring multiple streams of output, editing files side by side, or other tasks that benefit from a segmented display.

Action Command
Split pane horizontally Ctrl-b %
Split pane vertically Ctrl-b "
Move to another pane Ctrl-b Arrow key
Close pane Ctrl-b x
Swap panes Ctrl-b o
Show pane numbers Ctrl-b q

Miscellaneous

Aside from session, window, and pane management, tmux also offers a plethora of additional commands and features. For instance, you can view all the available commands, scroll through the history, or even set options for all sessions. This section provides some of these miscellaneous, but highly useful commands.

Action Command
See all commands Ctrl-b ?
Scroll through history Ctrl-b [ then use arrow keys to scroll and q to quit
Set option for all sessions tmux set -g option value

This cheat sheet provides a concise overview of the most commonly used tmux commands. However, tmux has many more features and commands. For a more comprehensive exploration, you can refer to the tmux man page by typing man tmux in your terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment