Thursday, August 16, 2018

tmux (session tool)


Introduction


The tool can help to reattach the losing sessions. It is really useful if your network connection is unstable. You can attach the losing session and keep working. In addition, it enables users to control window panes through keyboard.

Installation (Linux):

sudo apt-get update
sudo apt-get install tmux
tmux -V

To start:

In:
tmux new (it will use number to name the session)
tmux new -s name-of-session

Out:
exit
Prefix + d

Commands:


Note: all commands need a prefix  
Default prefix: 
                       ctrl + b

Session

Attach

 tmux a -t number-of-session
 tmux a -t name-of-session

Kill

 tmux kill-session -t number-of-session

List   

 tmux ls

Windows

New: 
  Prefix + c
Kill:  
  Prefix + ,
Moving:
                        Prefix + p
                        Prefix + n
                        Prefix + Number

Panes


New:
  Horizontally:
prefix + “
  Vertically:
prefix + %
Kill:
                        Prefix + x
Moving:
                        Prefix + up|down|left|right
                        Prefix + o

How to customize it?

The keyboard combination of prefix seems to be not that user friendly. If we can change it to something else, that will be really appreciated.

First, we need to create a tmux configuration file.
    vim ~/.tmux.conf

Copy the following instructions into that file.
    unbind c-b
    set -g prefix C-a
    bind C-a send-prefix

The above instructions mean that we change prefix from ctrl + b to ctrl + a.


Reload Config

tmux source-file ~/.tmux.conf

No comments:

Post a Comment