tmux 1.5—LINUX多窗口终端工具

On 2011年09月16日, in soft, by netoearth

tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

The latest version is tmux 1.5.

tmux uses a client-server model. The server holds multiple sessions and each window is an independent entity which may be freely linked to multiple sessions, moved between sessions and otherwise manipulated. Each session may be attached to (display and accept keyboard input from) multiple clients.

tmux is intended to be a modern, BSD-licensed alternative to programs such as GNU screen. Major features include:

  • A powerful, consistent, well-documented and easily scriptable command interface.
  • A window may be split horizontally and vertically into panes.
  • Panes can be freely moved and resized, or arranged into preset layouts.
  • Support for UTF-8 and 256-colour terminals.
  • Copy and paste with multiple buffers.
  • Interactive menus to select windows, sessions or clients.
  • Change the current window by searching for text in the target.
  • Terminal locking, manually or after a timeout.
  • A clean, easily extended, BSD-licensed codebase, under active development.

tmux is part of the OpenBSD base system. The portable version is hosted on SourceForge and runs on Linux, FreeBSD, NetBSD, Solaris and AIX.

tmux depends on libevent 1.4 or 2.0 and a terminfo implementation (normally ncurses).

A few people have written programs which can be used with tmux: tmux-ruby, tmuxinator, tmux-applets and teamocil.

Screenshot Screenshot Screenshot

Basic usage

In a terminal just write tmux and you’ll start it.
Now you can use a combination of keys to get some results, the most commons/useful i’ve saw so far are:

CTRL + b This combination it’s the default to tell tmux you are about to issue a command
CTRL + b " Split the current pane into two, top and bottom.
CTRL + b % Split the current pane into two, left and right.
CTRL + b arrow using the arrows you can change to the pane above, below, to the left, or to the right of the current pane
CTRL + b x Kill the current pane.
CTRL + b c Create a new window
CTRL + b l Move to the previously selected window.
CTRL + b n Move to the next window.
CTRL + b d Detach the client

Finally, I would like to nominate the copy & paste feature which I think is a really useful. To enter the Copy mode all you have to do is Ctrl + b [ and move up to what needs to be copied. Then press Ctrl + Space and select the text. Once selected, copy with Alt + w . To paste the text all you have to do is Ctrl + b ].


Once that you detach from tmux you’ll be back on terminal. From here you can use these commands:

1) List all sessions managed by the server with the parameter ls

#tmux ls
0: 2 windows (created Thu Sep 15 12:46:14 2011) [203x50]

#tmux attach -t 0

This will return your terminal to your detached session.

3) Destroy the given session, closing any windows linked to it and no other sessions, and detaching all clients attached to it with the parameter kill-session -t # of session

#tmux ls 
0: 2 windows (created Thu Sep 15 12:46:14 2011) [203x50]

#tmux kill-session -t 0

This will close the session and all the windows in our formerly detached session.


These are only the main options of tmux, check the man page for some more, this can be a great program to be used on server without graphical terminals, personally on desktops I still prefer to use smart terminal programs like terminator, they do perhaps less things but you don’t have to remember all the combinations of keys, and for a PC that your turn on and off every day it’s enough.
Regarding that in tmux you can customise all the combinations so they can be more user friendly.

Tagged with:  

Comments are closed.