Difference between pages "Talk:Funtoo Linux First Steps" and "Terminal Mutiplexers"

From Funtoo
(Difference between pages)
Jump to: navigation, search
(Default editor)
 
 
Line 1: Line 1:
== Default editor ==
+
= Introduction =
 +
GNU Screen and tmux are so called terminal multiplexers. At some point they may be considered as window managers for console, without X server. As multiplexers both screen/tmux manage multiple shell instances (windows) within a single session, allows detach/re-attach from session with running processes in their own windows.
 +
=== Comparison ===
 +
The following features are specific to tmux and not shared by GNU Screen.
 +
*Client/Server System
 +
When the first tmux session is created, a server instance is started automatically, and the session runs as a client for that server. Further sessions operate as clients, connecting to the same server instance. The user can enter commands at any client to control the server instance, the current session, or any other client of the same server instance.
 +
*Vertical Split
 +
Both tmux and GNU Screen allow horizontal screen splitting, but only tmux provides vertical splitting. A third-party patch has been produced for GNU Screen that adds vertical splitting (using V), and some Linux distributions do apply that patch to the default GNU Screen package. Apart from this patch, the current git version of screen has vertical split support (using |).
 +
*Synchronize-panes
 +
tmux can duplicate input to any pane to all other panes in the same window (not available for panes in special mode e.g. copy-mode). It provides you clusterssh like function to simultaneous input to all of the terms all at the same time
  
[[User:Aramis qc|Aramis qc]] 13:06, 10 February 2012 (UTC)
+
The following features are specific to GNU Screen and not shared by tmux.
 +
*Logging (probably outdated)
 +
In GNU Screen, you can set up logging for a detached session from within screen (Ctrl+a H). Therefore you don't have to think about redirecting output to files all the time. For example, you start some long remote compilation process and suddenly you have to disconnect, but still want to have the build log. In screen you just press (<C-a> H) combination and detach, the output is being logged.
 +
*Interface
 +
Whereas Screen uses Ctrl-A as its command prefix, interfering with the default command character in most shells for moving the cursor to the beginning of the line, the command prefix used by tmux is Ctrl-B, which interferes with the default command character in most shells for moving the cursor back one character without deleting. In case of a need to have standard shell behavior for Ctrl-A (in the case of Screen) or Ctrl-B (in the case of tmux), both applications can be configured to use a different command prefix. They both also provide a default command keybinding that can be used to send the requisite control character to whatever application the session contains -- "Ctrl-A A" in GNU Screen and "Ctrl-B Ctrl-B" in tmux.
 +
*Performance
 +
Tmux was created to provide a simple, modern, lightweight, BSD-licensed alternative to GNU Screen. In general, the design goals for tmux ensure it is a relatively fast and lightweight application. The client/server architecture also ensures that increases of resource usage for multiple sessions are minimized
 +
=== Installation ===
 +
<console>
 +
# ##i##emerge app-misc/screen
 +
or
 +
# ##i##emerge tmux
 +
</console>
 +
=== Basic usage ===
 +
^ is equal to ctrl+, for example ^x is Ctrl button+x button
 +
{| {{Table}}
 +
|Action||GNU screen||tmux
 +
|-
 +
|start a new session||screen||tmux
 +
|-
 +
|re-attach a detached session||screen -r||tmux -a or tmux attach
 +
|-
 +
|re-attach an attached session (detaching it from elsewhere)||screen -dr||tmux -ad or tmux attach -d
 +
|-
 +
|re-attach an attached session (keeping it attached elsewhere)||screen -x||tmux -a or tmux attach
 +
|-
 +
|detach from currently attached session||^a ^d or ^a :detach||^b d or ^b :detach
 +
|-
 +
|rename-window to newname||^a A <newname>||^b , <newname> or ^b :rename-window <newname>
 +
|-
 +
|list windows||^a w||^b w
 +
|-
 +
|list windows in chooseable menu||^a "||
 +
|-
 +
|go to window #||^a #||^b #
 +
|-
 +
|go to last-active window||^a l||^b l
 +
|-
 +
|go to next window||^a n||^b n
 +
|-
 +
|go to previous window||^a p||^b p
 +
|-
 +
|see keybindings||^a ?||^b ?
 +
|-
 +
|list sessions||screen -ls||^b s or tmux ls
 +
|-
 +
|toggle visual bell||^a ^g||
 +
|-
 +
|create another shell||^a c||^b c
 +
|-
 +
|exit current shell||^d||^d
 +
|-
 +
|split pane horizontally||||^b "
 +
|-
 +
|split pane vertically||||^b %
 +
|-
 +
|switch to another pane||||^b o
 +
|-
 +
|kill the current pane||||^b x OR (logout/^D)
 +
|-
 +
|close other panes except the current one||||^b !
 +
|-
 +
|swap location of panes||||^b ^o
 +
|-
 +
|show time||||^b t
 +
|-
 +
|show numeric values of panes||||^b q
 +
|}
  
According to Aleksey Frolov's suggestion on the mailing list, eselect should be used instead.
+
=== Configuration ===
 +
.screenrc
 +
.tmux.conf
  
== Installing a logger ==
+
example .tmux.conf (courtesy of slashbeast)
  
[[User:Aramis qc|Aramis qc]] 13:06, 10 February 2012 (UTC)
+
<console># Normal prefix a-la screen, ^b is ugly
 +
set-option -g prefix C-a 
 +
# Send prefix thru tmux, for example to underlaying screen.
 +
bind-key a send-prefix
  
Wouldn't be nice to have a link to tutorial about metalog. There's a man page but in my humble opinion there should be something about configuration of metalog.
+
# Toggle status bar
 +
bind-key b set-option status
 +
 
 +
# Toggle select pane/window by mouse
 +
bind-key m set-option mouse-select-pane \; set-option mouse-select-window
 +
 
 +
# Reload key.
 +
bind-key r source-file ~/.tmux.conf
 +
 
 +
# Split window into panes, horizontal or vertical.
 +
bind-key h split-window -h
 +
bind-key v split-window -v
 +
 
 +
# TERM variable and title.
 +
set -g default-terminal "screen-256color"
 +
set -g set-titles on
 +
set -g set-titles-string '#T [tmux]'
 +
 
 +
#set -g window-status-current-attr bold
 +
#set -g window-status-alert-attr bold
 +
#set -g monitor-activity on
 +
 
 +
# Start couting windows from 1
 +
set -g base-index 1
 +
 
 +
# Le colors and format of statusbar, menus etc.
 +
set -g message-bg black
 +
set -g message-fg colour252
 +
#set -g mode-bg colour252
 +
set -g mode-bg green
 +
set -g mode-fg black
 +
set -g status-bg colour233
 +
set -g status-fg white
 +
set -g status-left ''
 +
set -g status-right '#[fg=colour245] %d-%m-%Y %H:%M '
 +
set-window-option -g window-status-format ' #[fg=colour245]#I:#[fg=colour250]#W '
 +
set-window-option -g window-status-current-format '#[bg=black]#[fg=colour245] #I#[fg=colour245]:#[fg=colour252]#W '</console>

Latest revision as of 07:57, 13 April 2012

Introduction

GNU Screen and tmux are so called terminal multiplexers. At some point they may be considered as window managers for console, without X server. As multiplexers both screen/tmux manage multiple shell instances (windows) within a single session, allows detach/re-attach from session with running processes in their own windows.

Comparison

The following features are specific to tmux and not shared by GNU Screen.

  • Client/Server System

When the first tmux session is created, a server instance is started automatically, and the session runs as a client for that server. Further sessions operate as clients, connecting to the same server instance. The user can enter commands at any client to control the server instance, the current session, or any other client of the same server instance.

  • Vertical Split

Both tmux and GNU Screen allow horizontal screen splitting, but only tmux provides vertical splitting. A third-party patch has been produced for GNU Screen that adds vertical splitting (using V), and some Linux distributions do apply that patch to the default GNU Screen package. Apart from this patch, the current git version of screen has vertical split support (using |).

  • Synchronize-panes

tmux can duplicate input to any pane to all other panes in the same window (not available for panes in special mode e.g. copy-mode). It provides you clusterssh like function to simultaneous input to all of the terms all at the same time

The following features are specific to GNU Screen and not shared by tmux.

  • Logging (probably outdated)

In GNU Screen, you can set up logging for a detached session from within screen (Ctrl+a H). Therefore you don't have to think about redirecting output to files all the time. For example, you start some long remote compilation process and suddenly you have to disconnect, but still want to have the build log. In screen you just press (<C-a> H) combination and detach, the output is being logged.

  • Interface

Whereas Screen uses Ctrl-A as its command prefix, interfering with the default command character in most shells for moving the cursor to the beginning of the line, the command prefix used by tmux is Ctrl-B, which interferes with the default command character in most shells for moving the cursor back one character without deleting. In case of a need to have standard shell behavior for Ctrl-A (in the case of Screen) or Ctrl-B (in the case of tmux), both applications can be configured to use a different command prefix. They both also provide a default command keybinding that can be used to send the requisite control character to whatever application the session contains -- "Ctrl-A A" in GNU Screen and "Ctrl-B Ctrl-B" in tmux.

  • Performance

Tmux was created to provide a simple, modern, lightweight, BSD-licensed alternative to GNU Screen. In general, the design goals for tmux ensure it is a relatively fast and lightweight application. The client/server architecture also ensures that increases of resource usage for multiple sessions are minimized

Installation

# emerge app-misc/screen
or
# emerge tmux

Basic usage

^ is equal to ctrl+, for example ^x is Ctrl button+x button

Action GNU screen tmux
start a new session screen tmux
re-attach a detached session screen -r tmux -a or tmux attach
re-attach an attached session (detaching it from elsewhere) screen -dr tmux -ad or tmux attach -d
re-attach an attached session (keeping it attached elsewhere) screen -x tmux -a or tmux attach
detach from currently attached session ^a ^d or ^a :detach ^b d or ^b :detach
rename-window to newname ^a A <newname> ^b , <newname> or ^b :rename-window <newname>
list windows ^a w ^b w
list windows in chooseable menu ^a "
go to window # ^a # ^b #
go to last-active window ^a l ^b l
go to next window ^a n ^b n
go to previous window ^a p ^b p
see keybindings ^a ? ^b ?
list sessions screen -ls ^b s or tmux ls
toggle visual bell ^a ^g
create another shell ^a c ^b c
exit current shell ^d ^d
split pane horizontally ^b "
split pane vertically ^b %
switch to another pane ^b o
kill the current pane ^b x OR (logout/^D)
close other panes except the current one ^b !
swap location of panes ^b ^o
show time ^b t
show numeric values of panes ^b q

Configuration

.screenrc .tmux.conf

example .tmux.conf (courtesy of slashbeast)

# Normal prefix a-la screen, ^b is ugly
set-option -g prefix C-a  
# Send prefix thru tmux, for example to underlaying screen.
bind-key a send-prefix

# Toggle status bar
bind-key b set-option status

# Toggle select pane/window by mouse
bind-key m set-option mouse-select-pane \; set-option mouse-select-window

# Reload key.
bind-key r source-file ~/.tmux.conf

# Split window into panes, horizontal or vertical.
bind-key h split-window -h
bind-key v split-window -v

# TERM variable and title.
set -g default-terminal "screen-256color"
set -g set-titles on
set -g set-titles-string '#T [tmux]'

#set -g window-status-current-attr bold
#set -g window-status-alert-attr bold
#set -g monitor-activity on

# Start couting windows from 1
set -g base-index 1

# Le colors and format of statusbar, menus etc.
set -g message-bg black
set -g message-fg colour252
#set -g mode-bg colour252
set -g mode-bg green
set -g mode-fg black
set -g status-bg colour233
set -g status-fg white
set -g status-left ''
set -g status-right '#[fg=colour245] %d-%m-%Y %H:%M '
set-window-option -g window-status-format ' #[fg=colour245]#I:#[fg=colour250]#W '
set-window-option -g window-status-current-format '#[bg=black]#[fg=colour245] #I#[fg=colour245]:#[fg=colour252]#W '