https://tmux.github.io/ <-- Tmux project
http://z.umn.edu/tmuxgist <-- this document!
Crtl-b c
Create a new windowCrtl-b <N>
Switch to window<N>
Crtl-b ?
List available keystrokesCrtl-b ,
Rename current windowCrtl-b "
Split window horizontallyCrtl-b %
Split window verticallyCrtl-b <arrow>
Move around panes in the current windowCrtl-b w
List windows
(GNU screen
uses Ctrl-a
as its default prefix. Check Ctrl-a ?
for all bindings, many similar)
$ tmux new-session -s <name>
Create a new session named<name>
$ tmux list-sessions
List currently active sessions$ tmux attach -t <name>
Reattach to session named<name>
Crtl-b d
Detach session (leaving it running!)
There are LOTS AND LOTS of options configurable in $HOME/.tmux.conf
. Some useful things are:
set default-terminal "screen-256color"
for a sane & sensible$TERM
set -g mouse-select-pane on
allows you to click to select panesset -g mode-mouse on
Enables mouse/trackpad scrolling within the window (rather than scrolling the outer terminal)
A session can be shared with another user who has read/write access to the its socket.
# Start the Tmux session and give it a socket path
# The session's name is "shared"
$ tmux -S /tmp/shared-session.sock new-session -s shared
# Provide read/write access by changing its group
# This makes it accessible to ANYONE IN THE GROUP
$ chgrp sharedgrp /tmp/shared-session.sock
$ chmod g+rwx /tmp/shared-session.sock
Now another user may join your session.
# The other user's shell on the same server...
# Attach to the session named "shared" while passing the socket path
$ tmux -S /tmp/shared-session.sock attach -t shared
- When the second user attaches, that user is acting under the original user's account. The system sees only one user.
- You probably shouldn't create a shared session intending to persist it after everyone disconnects. (see previous)
- The Socket may not be removed when the session is terminated. Remove it manually
rm /tmp/shared-session.sock
- Don't
chmod 777
the socket! Create it in as limited way as possible to accomplish what you need. Ideally this would be by giving it group ownership to the smallest group to which you both belong.
tmate (http://tmate.io) supposedly makes sharing a little easier and is a fork of Tmux. I have not used it.
sshtmux()
{
# A name for the session
local session_name="$(whoami)_sess"
if [ ! -z $1 ]; then
ssh -t "$1" "tmux attach -t $session_name || tmux new -s $session_name"
else
echo "Usage: sshtmux HOSTNAME"
echo "You must specify a hostname"
fi
}
Tmux makes GNU Screen obsolete, being much easier to work with. Things Tmux can do which Screen can't include:
- Retaining split panes when detaching (this is UNBELIEVABLY IMPORTANT)
- Not requiring nested sessions (see previous)
- Vertical pane splitting without special patches
Screen allows for a password-protected session lock, Tmux does not have this feature (afaik).