TMUX - Let's Multitask
Getting Started
Before doing anything I recommend you getting oh-my-tmux.
cd ~
git clone https://github.com/gpakosz/.tmux.git
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
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
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.
-
Use Ctrl+Z to suspend the process.
-
Resume the process in the background with
bg
-
Find the process ID of the background process with
jobs -l
You'll see something similar to this:
-
Disown the job from the current parent (shell) with
disown yourprocessname
-
Start
tmux
(preferred), orscreen
. -
Reattach the process to the
tmux
/screen
session with reptyr: -
Now you can detach the multiplexer (default Ctrl+B, D for
tmux
, or Ctrl+A, D forscreen
), and disconnect SSH while your process continues intmux
/screen
. -
Later when you connect with SSH again, you can then attach to your multiplexer (e.g.
tmux attach
).