Skip to content

Instantly share code, notes, and snippets.

@bdlangton
Last active December 28, 2021 03:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bdlangton/e887b1576c17a1f9225a17fca37f03fb to your computer and use it in GitHub Desktop.
Save bdlangton/e887b1576c17a1f9225a17fca37f03fb to your computer and use it in GitHub Desktop.
Tmux Commands

NOTE: All commands that start with tmux can be executed within a tmux session by typing prefix, followed by :, then type the rest of the command (after tmux).

There is a binary script called tat that can be run and it will create a new session named after the directory that you are currently in. If a session with that name already exists, it will just open that session.

Sessions

Command Description
tmux new -s [session name] Start new named session
prefix s Choose a different session using fzf (custom mapping)
tmux ls List sessions
tmux a -t [name of session] Attach to named session
tmux a # Attach most recent session
tmux detach
prefix d
Detach from session
prefix D Choose a client to detach
prefix $ Rename session
prefix B Break out of the current session, creating a new session named after the cwd (custom mapping)
tmux switch -t [name of session] Switch to another session
prefix Ctrl+x Choose using fzf a specific session to kill (custom mapping)
prefix X Kill current session and switch to a different session so you stay in tmux (custom mapping)
tmux kill-session -t [name of session] Kill named session
tmux rename-session [-t name_of_session] new_name Rename the session

Windows

Command Description
tmux new-window
prefix c
Create a new window
prefix w Choose a different window using fzf (custom mapping)
prefix C Create a new window and prompt for the window name (custom mapping)
tmux select-window (selectw) -t :0-9
prefix 0-9
Go to another window
tmux rename-window (renamew)
prefix ,
Rename the current window
tmux list-windows (lsw) List windows
Ctrl+Shift+Left/Right Move current window left/right
tmux next-window (next)
prefix n
Go to next window
tmux previous-window (prev)
prefix p
Go to previous window
tmux find-window (findw)
prefix f
Find a window
tmux kill-window (killw)
prefix &
Kill window

Panes

Command Description
tmux split-window (splitw) -h
prefix "
prefix \
Split panes horizontally (custom mapping)
tmux split-window (splitw)
prefix %
prefix -
Split panes vertically (custom mapping)
prefix [arrow key]
Ctrl+[hjkl]
prefix [hjkl]
Move to another pane
Shift+[arrow key] Fine grained adjustments of the size of the pane
tmux swap-pane -[UDLR]
prefix { or }
Swap pane with another in the specified direction ({ is up, } is down)
tmux select-pane (selectp) -[UDLR] Select pane in the specified direction
tmux select-pane (selectp) -t :.+ Select the next pane in numerical order
prefix z Toggle pane zoom
prefix q Show pane numbers (when numbers are showing, type number to go to that pane)
prefix x Kill current pane
prefix J Choose a window to join to the current window (custom mapping)
prefix S Choose a window to send the current pane to (custom mapping)
tmux break-pane
prefix !
Break existing pane into new window

Execute Commands in Split Window

Command Description
Ctrl+x Prompts to execute any command in a split window. If your command returns to the prompt you'll need to pipe to 'less' (custom mapping)
Ctrl+\ Open interactive php in split window (custom mapping)

General

Command Description
tmux list-commands (lscm) List all commands available
tmux list-keys (lsk)
prefix ?
List every key and the command it is bound to
tmux info List every session, window, pane, it's pid, etc
prefix [ Enter copy mode (like vim)
prefix ] Paste the most recently copied buffer
= Choose which buffer to paste from
tmux source-file ~/.tmux.conf
prefix R
Reload the config file
tmux kill-server Kill tmux server, along with all sessions
tmux list-buffers
prefix #
List all paste buffers

Tmuxinator

Command Description
mux Alias to run tmuxinator
mux start project [--attach=false] Starts a project named 'project'
Add --attach=false if not wanting to attach the project
mux list List projects configured
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment