📜 ⬆️ ⬇️

Tmux Cheat Sheet (Terminal Multiplexer)


On Habrahabr Tmux (ti-max) was mentioned repeatedly, however, decided to write another cheat sheet, because in others, some important points are not shown.

Tmux (terminal multiplexer) allows you to work with several sessions in 1 window. Instead of several windows of the terminal to the server - you can use one. Allows you to connect / disconnect to the current state of the session. Running programs and processes continue to work. (Can be used instead of nohup, dtach).

For example, at work, edit the files in Vim. Terminal window with open files, processes. Disconnect from the session. Next, we connect to this session from home and get the same windows with open files in Vim, processes, etc. You can continue to work from the same point at which you stopped. Also handy when you break the connection. Additionally, you can work with others in the terminal, if you are connected to the same session. Everyone sees what the other is doing.

1. Installation


CentOS (   EPEL) # yum install tmux Fedora # dnf install tmux Ubuntu/Debian # apt-get install tmux 

2. Configuration Files


(user, system):
')
 ~/.tmux.conf /etc/tmux.conf 

From version 2.1, to enable mouse mode (scroll, resize panel, select panel, etc.) you need to add to tmux.conf:

 set -g mouse on 

To version 2.1

 set -g mouse-resize-pane on set -g mouse-select-pane on set -g mouse-select-window on set -g mode-mouse on 

3. Work with Tmux


Start
# tmux // without parameters, session 0 will be created
# tmux new -s session1 // new session session1. The name is displayed from the bottom-left in square brackets in the status line. Next is the listing of windows. The current window is marked with an asterisk.

Prefix (commands begin with it)
<Cb> (CTRL + b)

New window (press CTRL + b, then click with)
<Cb c>

Window list
<Cb w> // switch up and down

Switching
<Cb n> // next window
<Cb p> // previous window
<Cb 0> // switch to window number

Windows can be divided into panels (Panes)
As in tile (mosaic) window managers.

Dividing the window horizontally
<Cb ">
either team
# tmux split-window -h

Dividing the window vertically
<Cb%>
either team
# tmux split-window -v

Transition between panels
<Cb cursor arrows> // mouse mode

Resizing panels
<Cb c-arrows> // mouse mode

Closing windows
<Cb x> // need to confirm y
or
# exit

Disconnect from session
<Cb d>
or
# tmux detach

List of sessions
# tmux ls

Connect to a running session
# tmux attach // connection to the session, either to the only one or to the last one created
# tmux attach -t session1 // connection to session1

Select session
<Cb s>

Session Completion
# tmux kill-session -t session1

Complete all sessions
# tmux kill-server

List of supported commands
# tmux list-commands

Additional Information
# man tmux

Official website
Another well-known multiplexer Screen

I will be glad to any additions and comments.

Source: https://habr.com/ru/post/327630/


All Articles