Skip to content

TMUX - Let's Multitask

Getting Started

Before doing anything I recommend you getting oh-my-tmux.

cd ~
git clone
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .

However if you can not for whatever reason vanilla tmux and oh-my-tmux share almost all the same keybindings.

Starting Tmux

New Session

tmux new -s myname # New Named Session

Joining a Session

tmux ls # List the sessions
tmux -a X # X is the session number
tmux -a -t myname # Join a session by name

Ending a Session

tmux kill-session -t myname

Using TMUX

In tmux, you have to prefix ctrl+b each command you do. That way it knows when you're giving tmux a command vs just typing out something.

Session Management

:new<CR> new session
s list sessions
$ name session

## Windows (tabs)

c           new window
,           name window
w           list windows
f           find window
&           kill window
.           move window - prompted for a new number
:movew<CR>  move window to the next unused number

## Panes (splits)

%  horizontal split
"  vertical split

o  swap panes
q  show pane numbers
x  kill pane
⍽  space - toggle between layouts

## Window/pane Surgery

:joinp -s :2<CR>  move window 2 into a new pane in the current window
:joinp -t :1<CR>  move the current pane into a new pane in window 1

## Misc

d  detach
t  big clock
?  list shortcuts
:  prompt

Oops I Need to Disconnect

This works, most of the time:

Prerequisites: have reptyr and tmux/screen installed; you'll be able to find them with apt-get or yum, depending on your platform.

  1. Use Ctrl+Z to suspend the process.

  2. Resume the process in the background with bg

  3. Find the process ID of the background process with jobs -l

    You'll see something similar to this:

    [1]+ 11475 Stopped (signal) yourprocessname
  4. Disown the job from the current parent (shell) with disown yourprocessname

  5. Start tmux (preferred), or screen.

  6. Reattach the process to the tmux/screen session with reptyr:

    reptyr 11475
  7. Now you can detach the multiplexer (default Ctrl+B, D for tmux, or Ctrl+A, D for screen), and disconnect SSH while your process continues in tmux/screen.

  8. Later when you connect with SSH again, you can then attach to your multiplexer (e.g. tmux attach).