Blog Tags: 

tmux is a superior alternative to screen

Today was the first day I stopped using screen and started using tmux, which is a superior alternative which supports a more complex range of splits and has a nicer interface. It's a bit different from screen in that it has this concept of windows and panes. A tmux pane is a window (e.g., shell session) in screen terminology. A tmux window is a layout of panes (e.g., two windows side by side). A tmux window could have only one pane, or it could have an arbitrarily complex configuration of panes.

My initial impetus for investigating screen alternatives is that I hated having to run more than one terminal to on my screen to get the layout I wanted. I also find it infuriating to have to use the mouse to setup my terminal workspace.

Important commands:

tmux            start new tmux session
tmux attach     attach to existing tmux session

Important default key bindings

Tmux uses C-b instead of C-a as the control character. Which is great since C-a actually means something in shell-land (move to the start of the command)

Here is a shorthand listing of keys. Prepend C-b to invoke them.

General:

?                           full list of key bindings
d                           detach from tmux session
C-z                         suspend tmux

Pane keys:

"                           split horizontally
%                           split vertically
x                           kill current pane

up/down/right/left          navigate between window panes
                            (you can also click on the pane with the
                            mouse)

C-up/down/right/left        resize window pane

space                       automatic re-layout of panes
}                           swap pane in layout forward
{                           swap pane in layout backward

Cut and paste / clipboard keys:

[                           copy mode (cut and paste with keyboard)

                            Copy mode has its own key bindings:

                                cursors + page-up/page-down: move around
                                space: start selection
                                enter: copy selection

]                           paste buffer

C-c                         copy buffer to X clipboard
C-v                         paste buffer from X clipboard

Window keys:

c                           create new window
1-9                         switch to window number ...
n                           next window
p                           previous window
,                           rename window

!                           maximize current pane

Advanced:

:                           command line mode
:list-commands              list commands

My tmux configuration file:

cat > $HOME/.tmux.conf << EOF

set -g status off
set -g mouse-select-pane on
set -g base-index 1
set-window-option -g mode-keys vi
set-window-option -g mode-mouse on

bind-key C-c run-shell "tmux show-buffer | xclip -i"
bind-key C-v run-shell "tmux set-buffer \\"$(xclip -o)\\"; tmux paste-buffer"

EOF

Comments

Jeremiah's picture

I really like tmux too and I've been using it for some years now. You may also want to try byobu, from Dustin Kirkland, which uses tmux but adds nice default keybindings as well as some other nice features.

http://byobu.co/

Liraz Siri's picture

Hi Jeremiah, Alon recommended I try out byobu 4 years ago and I think we briefly considered making it the default. I remember there was a problem that prevented us from doing that but to be honest I don't remember what that was. It's probably evolved since so maybe I should give it another try.

Luis Tineo's picture

Honestly I cannot name another tool that I love as much as I do Byobu. That said, Byobu uses either screen or tmux as a backend so tmux for me its better than screen!

Keith's picture

Without doubt byobu as well. Just want to add that until a few months back I was using tmux and then noticed someone using byobu on a screencast and gave it another go. Well now I have byobu everywhere, it's available on all Distro's, Ubuntu/Debian/CentOS/Redhat and I even use it on my MacBook Air!
 

Pages

Add new comment