Creating a new session
tmux
tmux new-session -s'my rails project'
The default prefix is ctrl+b
, I will refer to this as the PREFIX, then you need to enter the command.
Leaving the current session (deattaching from session, it will continue running on the server).
PREFIX + d
Attaching to an existing server's session
tmux attach-session -t <session-name>
The server
holds sessions
and the windows
and panes
within them.
The active window will have a * symbol next to it.
Switching between sessions within the same tmux client
PREFIX + s
tmux switch-client -t <session-name>
Renaming an existing session
PREFIX + $
tmux rename-session -t "<current-session-name>" "<new-session-name>"
Does this session exist?
tmux has-session -t <session-name>
You’ll always be attached to a session when you’re using a client in tmux. When the last remaining session is closed, the server will close also. Think of sessions as workspaces designed to help organize a set of windows.
Creating new windows.
PREFIX + c
The first window’s index is 0
, unless you set it via base-index
in your configuration.
Naming windows
PREFIX + ,
Traversing windows
PREFIX + p
PREFIX + n
PREFIX + <window-index>
PREFIX + '
PREFIX + w
Switching windows layouts
PREFIX + space
Closing windows
tmux kill-window
tmux kill-window -t<window-index>
Panes are pseudoterminals encapsulating shells (e.g., Bash, Zsh). A terminal within a terminal.
Creating new panes. A normal window will usually have 1 to 5 panes open.
PREFIX + % or tmux split-window -h
PREFIX + " or tmux split-window -v
Creating a new pane, split vertically with 75% height
tmux split-window -p 75
Creating pane horizontally, $HOME directory, 50% width of current pane
tmux split-window -h -c $HOME -p 50 vim
Traversing Panes
PREFIX + [up/down/left/right] keys
To zoom in on a pane, navigate to it and do
PREFIX + z
tmux resize-pane -Z
Resizing panes
tmux resize-pane -U 5
tmux resize-pane -D 5
tmux resize-pane -L 5
tmux resize-pane -R 5
tmux resize-pane -U
tmux resize-pane -D
tmux resize-pane -L
tmux resize-pane -R
Closing panes
PREFIX + x
Showing pane's numbers
PREFIX + q
Entering scroll mode within a pane. Press q
to quit scroll mode.
PREFIX + [ then you can use arrows to move up/down