Maximizing Productivity: A Comprehensive Guide to Tmux - Boost Your Terminal Efficiency

Tmux Cheat Sheet: Essential Commands and Keyboard Shortcuts

Tmux is a powerful terminal multiplexer that allows you to manage multiple terminal sessions within a single window. It can greatly enhance your productivity and workflow when working on the command line. In this cheat sheet, we'll cover some essential commands and keyboard shortcuts to help you get started with Tmux.



Creating and Managing Sessions

To create a new Tmux session:

tmux new -s session_name

To attach to an existing session:

tmux a -t session_name

To kill a session:

tmux kill-session -t session_name

To list all active sessions:

tmux ls

To exit a Tmux session:

exit

Keyboard Shortcuts

Here are some useful keyboard shortcuts for navigating and managing Tmux:

Ctrl-b % - Split the current pane vertically.
Ctrl-b " - Split the current pane horizontally.
Ctrl-b arrow key - Move between panes.
Ctrl-b c - Create a new window.
Ctrl-b n - Move to the next window.
Ctrl-b p - Move to the previous window.
Ctrl-b d - Detach from the current session.

Note: To use these shortcuts, press Ctrl+b first, release it, and then press the corresponding key.

Additional Window Management Commands

Here are some additional commands for managing windows within Tmux:

  • c - Create a new window
  • n/p - Move to the next/previous window
  • 0-9 - Move to window number 0-9
  • l - Move to the previously selected window
  • f - Find a window by name
  • w - Show a menu with all windows
  • & - Kill the current window
  • , - Rename the current window
  • % - Split the window vertically
  • " - Split the window horizontally
  • space - Toggle between pane layouts
  • ! - Convert pane into a window
  • ctrl+(↑ ↓) - Resize current pane height (after Prefix, hold down the Ctrl key while tapping the up or down key)
  • Ctrl + (← →) - Resize current pane width (after Prefix, hold down the Ctrl key while tapping the right or left key)
  • x - Close current pane
  • o - Switch to the next pane
  • z - Toggle pane zoom
  • -
  • -
  • -
  • q - Show pane numbers (used to switch between panes)
  • Ctrl-b ? - List all keybindings

For a more detailed list of keybindings and commands, you can refer to the Tmux manual or execute tmux list-keys within a Tmux session.

Customizing Tmux

You can customize Tmux by editing the configuration file located at ~/.tmux.conf. Here are a few examples of customizations:

# Enable mouse scrolling
set -g mouse on

Customizing Tmux (continued)

# Enable two prefix keys
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
Set the status bar to display in the bottom
set-option -g status-position bottom

Set the status bar colors
set-option -g status-style fg=white,bg=black

Customize the window list format
set-option -g window-status-format " #[fg=yellow]#I:#W#[fg=default]"

Set the window list colors
set-option -g window-status-current-style fg=black,bg=yellow

Customize the pane border colors
set-option -g pane-active-border-style fg=green
set-option -g pane-border-style fg=default

Set the default shell
set-option -g default-shell "/bin/bash"

These are just a few examples of customizations you can make to your Tmux configuration. Feel free to explore the Tmux manual and experiment with different settings to suit your preferences.

Remember to save the changes to your ~/.tmux.conf file and restart your Tmux session for the new settings to take effect.

With these essential commands, keyboard shortcuts, and customization options, you'll be able to enhance your productivity and efficiently manage multiple terminal sessions using Tmux.

Enjoy using Tmux!

Next Post Previous Post
No Comment
Add Comment
comment url