Book Image

Getting Started with tmux

By : Victor Quinn
Book Image

Getting Started with tmux

By: Victor Quinn

Overview of this book

Table of Contents (16 chapters)
Getting Started with tmux
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Key binding and command reference


This is not intended as an exhaustive reference on tmux key bindings and commands. For that, view the tmux manual page by typing the following in your terminal:

$ man tmux

You can also view more information on tmux by visiting http://man.cx/tmux.

This is, instead, a chapter-by-chapter reference for the tmux keys and commands mentioned in each chapter along with a small description of what they do in the order in which they are mentioned.

This makes it easy to review and recall these key bindings and commands in the same order that they were covered in the chapter without having to wade through all of the text of that chapter.

Chapter 1 – Jump Right In

In this chapter, we jumped right in and went on a tour of many of the features of tmux. As a result, the following list of commands is widely varied:

  • Launch tmux: $ tmux

  • Rename a session: $ tmux rename-session {session name}

  • Create a new window: <Prefix>, c

  • Switch to the last window: <Prefix>, l

  • Switch to a window by its index: <Prefix>, {index of window}

  • List all key bindings: <Prefix>, ?

  • Initiate a search within the key bindings list: Ctrl + s (or / for vi users)

  • Close any dialog opened by tmux, such as the key bindings list: q

  • Open the choose window interface: <Prefix>, w

  • Switch to the next window (by the window index): <Prefix>, n

  • Switch to the previous window (by the window index): <Prefix>, p

  • Find an open window with the specified search text: <Prefix>, f

  • Detach the current tmux session: <Prefix>, d

  • List all active sessions: $ tmux list-sessions

  • Start tmux and attach a session by name: $ tmux attach-session -t {session-name}

  • A shorter way to start tmux and attach a session: $ tmux attach -t {session-name}

  • An even shorter way to start tmux and attach a session (only works when there is a single active session): $ tmux attach

  • List all active sessions' aliases: $ tmux ls

  • List all tmux commands: $ tmux list-commands

  • List all tmux commands' aliases: $ tmux lscm

  • Rename the current window: <Prefix>, ,

  • Kill the current window: <Prefix>, &

Chapter 2 – Configuring tmux

In this chapter, we dealt a lot with configuration. Listed here are the key bindings and commands introduced in Chapter 2, Configuring tmux, but see the Configuration reference section for information on the new configuration items we discussed:

  • Set a tmux option: $ tmux set-option {option to set} {value}

  • Disable the status bar: $ tmux set-option status off

  • Enable the status bar: $ tmux set-option status on

  • See whether you are in the Emacs or vi mode: $ tmux show-options –g | grep key

  • Reload the tmux configuration: $ tmux source-file ~/.tmux.conf

  • Show all previously displayed messages: <Prefix>, ~

Chapter 3 – Sessions, Windows, and Panes

In Chapter 3, Sessions, Windows, and Panes, we learned all about how to move and organize your content within a terminal window using the three core building blocks of tmux: sessions, windows, and panes. As a result, the key commands we learned throughout this chapter relate to manipulating one of those three items. The key commands covered in this chapter are as follows:

  • Launch tmux with a named session: $ tmux new-session –s {session name}

  • Access the switch session interactive dialog: <Prefix>, s

  • Switch to the next session: <Prefix>, )

  • Switch to the previous session: <Prefix>, (

  • Split a pane into two panes (horizontally): <Prefix>, %

  • Switch the cursor to the other pane: <Prefix>, o

  • Move the cursor to the pane to the right, left, down, or up: <Prefix>, right arrow; <Prefix>, left arrow; <Prefix>, down arrow; <Prefix>, up arrow

  • Kill the current pane: <Prefix>, x

  • Split a pane into two panes (vertically): <Prefix>, "

  • Resize the current pane: <Prefix>, Alt + {arrow key}

  • Resize the current pane in 1 cell steps: <Prefix>, Ctrl + {arrow key}

  • View current pane indexes: <Prefix>, q

  • Switch to the pane by index: <Prefix>, q, {index of pane}

  • Cycle through pane layouts: <Prefix>, Space

  • Switch to the even-horizontal pane layout: <Prefix>, Meta + 1

  • Switch to the even-vertical pane layout: <Prefix>, Meta + 2

  • Switch to the main-horizontal pane layout: <Prefix>, Meta + 3

  • Switch to the main-vertical pane layout: <Prefix>, Meta + 4

  • Switch to the tile pane layout: <Prefix>, Meta + 5

Chapter 4 – Manipulating Text

We spent this chapter learning about Copy mode, paste buffers, and other concepts related to text manipulation.

  • Clear the tmux history: $ tmux clear-history

  • Enter Copy mode: <Prefix>, [

  • Enter Command mode: <Prefix>, :

  • Enter Clock mode: <Prefix>, t

  • View the Emacs key bindings for Copy mode: tmux list-keys -t emacs-copy

  • View the vi key bindings for Copy mode: tmux list-keys -t vi-copy

    Note

    Many of the following commands are valid only after entering Copy mode. We will start these commands with [CM] to indicate that Copy mode should be activated first.

    This is also the first command set that really has two different modes, Emacs and vi mode. As such, each command actually has two different key bindings, depending on your chosen mode. We will display the default key binding (Emacs) first, and then we will display the alternative (vi) in parentheses.

    For the Emacs key bindings, many involve the key Meta, which is often bound to the Alt / Option key and is a key to which any Emacs user should be accustomed.

    We discussed how to set the mode keys as Emacs or vi back in Chapter 2, Configuring tmux.

  • [CM] Scroll up by page: Page Up or Meta + v (Ctrl + b)

  • [CM] Scroll down by page: Page Down or Ctrl + v (Ctrl + f)

  • [CM] Move the cursor up: up arrow or Ctrl + p (k)

  • [CM] Move the cursor down: down arrow or Ctrl + n (j)

  • [CM] Move the cursor left: left arrow or Ctrl + b (h)

  • [CM] Move the cursor right: right arrow or Ctrl + f (l)

  • [CM] Jump to top of window history: Meta + > (g)

  • [CM] Jump to bottom of window history: Meta + < (G)

  • [CM] Search up: Ctrl + r (?)

  • [CM] Search down: Ctrl + s (/)

  • [CM] Jump to a specific line: g (:)

  • [CM] Exit Copy mode: q (Esc)

  • [CM] Start the selection for copying: Ctrl + Space bar (Space bar)

  • [CM] Copy the selection to the paste buffer: Meta + w (Enter)

  • [CM] Toggle the rectangular selection: R (v)

  • Paste the text from the paste buffer: <Prefix>, ]

  • Open the interactive paste buffer chooser: <Prefix>, =

  • List all buffers for viewing only: <Prefix>, :, list + buffers, Enter

Chapter 5 – Diving Deeper

In this chapter, we went a bit more in depth on a smorgasbord of topics. As a result, our keyboard commands and configuration items for this chapter are quite widely varied over a range of tmux capabilities:

  • Enter Command mode: <Prefix>, :

  • Open the interactive paste buffer chooser: <Prefix>, =

  • Save the paste buffer to a path: save-buffer –b {buffer index} {file path}

  • Load the paste buffer from a file: load-buffer {file-path}

  • Set a paste buffer directly: set-buffer "{text to set in buffer}"

  • Capture contents of the current pane to the paste buffer: capture-pane

  • View the contents of the most recently copied paste buffer: show-buffer

  • View the contents of a paste buffer by index: show-buffer –b {index}

  • Delete the last copied item from the paste buffer: <Prefix>, -

  • Delete items from the paste buffer by index: delete-buffer –b {index}

  • Clear the tmux history for the current pane: clear-history

  • Clear the tmux history for a pane by index: clear-history –t {index}

  • Move the window from one session to another: move-window or <Prefix>, .

  • Link a window between two sessions: link-window –t {target session}

  • Unlink the window from the current session: unlink-window

  • Break the current pane from the current window: <Prefix>, !

  • Break a pane into its own window: break-pane –s {session}:{window}.{pane}

  • Join the current pane to a target window: join-pane -t {session}:{window}

  • Join a pane to a target window: join-pane -s {session}:{window}.{pane} -t {session}:{window}