Skip to content

Instantly share code, notes, and snippets.

@ismet55555
Last active May 23, 2024 21:22
Show Gist options
  • Save ismet55555/f78cecaab16d7a0acf786ab6b11c7d56 to your computer and use it in GitHub Desktop.
Save ismet55555/f78cecaab16d7a0acf786ab6b11c7d56 to your computer and use it in GitHub Desktop.
tmux Basics

tmux Basics

Installation

Note

Commands

These are run in the terminal outside tmux

Command Description
tmux Starts a tmux session
tmux new -s <SESSION NAME> Starts a named tmux session
tmux ls List all active tmux sessions
tmux kill -session -t <SESSION NAME> Kill a tmux session
tmux attach <SESSION NUMBER> Attach to session using session number
tmux attach -t <SESSION NAME> Attach to a session using session name

General - Keyboard Shortcuts

Shortcut Description
CTRL + B ? Show all tmux shortcuts
CTRL + B w Navigate / browse tmux sessions and windows
CTRL + B d Detach from current session

Panes - Keyboard Shortcuts

Shortcut Description
CTRL + B + <ARROW KEY> Resize currently active pane
CTRL + B <ARROW KEY> Switch active pane
CTRL + B % Split current pane vertically
CTRL + B " Split current pane horizontally
CTRL + B SPACEBAR Switch current pane orientation
CTRL + B z Full screen a pane

Window Control - Keyboard Shortcuts

Shortcut Description
CTRL + B c Create new window
tmux rename-window <NAME> Rename the current window
CTRL + B w List and choose specific window and pane
CTRL + B , Go to named window
CTRL + B n Go to next window
CTRL + B p Go to previous window

Copy/Paste - Keyboard Shortcuts

Shortcut Description
CTRL + B [ Enter copy mode
CTRL + SPACEBAR Select text in copy mode
ALT + W Confirm text selection in copy mode (Will exit copy mode)
CTRL + c Exit copy mode
CTRL + B ] Paste copied text

Organization

These commands can be run within tmux

Shortcut Description
tmux rename-session Rename current session
tmux rename-window Rename current window
tmux swap-window -s <WIN INDEX> -t <WIN INDEX> Swap window positions
tmux move-window -s <SES>:<WIN> -t <SES>:<WIN> Move a window to another session
tmux move-pane -s <SES>:<WIN> -t <SES>:<WIN> Move a pane to another window

Plugins and Configurations (~/.tmux.conf)

  1. Add tmux configuration file .tmux.conf to home directory (ie. ~/.tmux.conf)

  2. Install Tmux Package manager

    • Run in terminal:
      • git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
    • Add at END of .tmux.conf:
      • set -g @plugin 'tmux-plugins/tpm'
      • run '~/.tmux/plugins/tpm/tpm'
  3. Add plugins into configuration file

    • Example: set -g @plugin 'tmux-plugins/tmux-resurrect' (Adding tmux-resurrect plugin)
    • Example: set -g @plugin 'tmux-plugins/tmux-yank' (Adding tmux-yank plugin)
  4. Add configurations

    • Example: set -g mouse on (Turn on mouse mode)
  5. After changing tmux.conf, still in tmux press CTRL + B I to refresh and install

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