Skip to content

Instantly share code, notes, and snippets.

@vyraun
Forked from henrik/tmux_cheatsheet.markdown
Last active March 14, 2019 23:25
Show Gist options
  • Save vyraun/e5d72720cb05af0a8f62c8a8cf67e494 to your computer and use it in GitHub Desktop.
Save vyraun/e5d72720cb05af0a8f62c8a8cf67e494 to your computer and use it in GitHub Desktop.
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

tmux new -s myname

attach:

tmux a  #  (or at, or attach)

attach to named:

tmux a -t myname

list sessions:

tmux ls

kill session:

tmux kill-session -t myname

In tmux, hit the prefix ctrl+b and then:

Sessions

: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

Resources:

Notes:

  • You can cmd+click URLs to open in iTerm.

TODO:

  • Conf copy mode to use system clipboard. See PragProg book.

You should look for modern alternatives like tmux.

tmux is superior to screen for many reasons, here are just some examples:

Windows can be moved between session and even linked to multiple sessions Windows can be split horizontally and vertically into panes Support for UTF-8 and 256 colour terminals Sessions can be controlled from the shell without the need to enter a session Basic Functionality To get the same functionality as explained in the answer recommending screen, you would need to do the following:

ssh into the remote machine start tmux by typing tmux into the shell start the process you want inside the started tmux session leave/detach the tmux session by typing Ctrl+b and then d You can now safely log off from the remote machine, your process will keep running inside tmux. When you come back again and want to check the status of your process you can use tmux attach to attach to your tmux session.

If you want to have multiple sessions running side-by-side, you should name each session using Ctrl+b and $. You can get a list of the currently running sessions using tmux list-sessions, now attach to a running session with command tmux attach-session -t 0.

tmux can do much more advanced things than handle a single window in a single session. For more information have a look in man tmux or the tmux GitHub page. In particular, here's an FAQ about the main differences between screen and tmux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment