tmux

From Gentoo Wiki
Jump to: navigation, search

External resources

tmux (terminal multiplexer) is a program that enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. Users familiar with GNU Screen may find that tmux is a good alternative.

Contents

Installation

Install app-misc/tmux:

→ Information about USE flags
USE flag Default Recommended Description
vim-syntax No Yes Pulls in related vim syntax scripts
root # emerge --ask tmux

The configuration files are located in ~/.tmux.conf

Usage

Start session

Once started tmux will create a socket for the session in /tmp/S-<UID>/<Session Name>

tmux can be started with the following command:

user $ tmux

tmux can be controlled from an attached client by using a key combination of a prefix key, Ctrl+b by default, followed by a command key.

Give the session a reasonable name on startup:

user $ tmux new-session -s portage

Start a command in a screen session without attaching to it (like a daemon):

user $ tmux new-session -d 'emerge -uDNvp @world'

Key Binds

After pressing Ctrl+b the following key combinations can be used:

General

  • ? = List all key bindings.
  • d = Detach the current client.
  • : = Enter the tmux command prompt.

Creating/Managing windows

  • c = Create a new window
  • n = Change to the next window.
  • p = Change to the previous window.
  • l = Move to the previously selected window.
  • 0-9 = Select windows 0 to 9.
  • ' = Prompt for a window index to select. Then enter a number or title to switch to that window.
  • , = Rename the current window.
  • w = Choose the current window interactively.
  • :, then type list-windows enter = Display the list of windows.

Creating/Managing panes

  • " = Split the current pane into two, top and bottom.
  • % = Split the current pane into two, left and right.
  • o = Select the next pane in the current window.
  • ; = Move to the previously active pane.
  • { = Swap the current pane with the previous pane.
  • } = Swap the current pane with the next pane.
  • Ctrl+o = Rotate the panes in the current window forwards.
  • Alt+1 to Alt+5 = Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
  • x = Kill the current pane.
  • ! = Break the current pane out of the window.

Copy, Paste and Scroll operations

The keys available depend on whether emacs (default) or vi mode is selected. The mode-keys option can be set int .tmux.conf for vi mode.

  • [ = Enter copy mode to copy text or view the history.
  • ] = Paste the most recently copied buffer of text.
  • # = List all paste buffers.
  • - = Delete the most recently copied buffer of text.

Resume Session

After the session is detached, all the active terminals remain active and so do commands that didn't finish yet. To list existing sessions:

user $ tmux list-sessions
standard: 5 windows (created Wed Jul  4 22:12:03 2012) [118x49]

To resume this session:

user $ tmux attach -t standard

Example .tmux.conf

File~/.tmux.conf

set -g default-terminal "screen-256color"   # use 256 colors
set -g status-utf8 on                       # enable utf-8
set -g history-limit 100000                 # scrollback buffer n lines

# start window indexing at one instead of zero
set -g base-index 1

# set the prefix key and some key bindings to match GNU Screen
set -g prefix C-a
bind-key C-a last-window

# key bindings for horizontal and vertical panes
unbind %
bind | split-window -h
bind - split-window -v

# enable window titles
#set -g set-titles on

# window title string (uses statusbar variables)
set -g set-titles-string '#T'

# status bar with load and time
set -g status-bg '#4e4e4e'
set -g status-fg '#ffffff'
set -g status-left ' '
set -g status-right '#[bg=#bbbbbb]#[fg=#000000]#(cut -d " " -f -3 /proc/loadavg) #[bg=#4e4e4e]#[fg=#ffffff]#(
date +" %H:%M ")'
set -g window-status-format '#I #W'
set -g window-status-current-format ' #I #W '
setw -g window-status-current-bg '#55ff55'
setw -g window-status-current-fg '#000000'

# pane border colors
set -g pane-active-border-fg '#bbbbbb'
set -g pane-border-fg '#555555'

# bind to reload config
bind r source-file ~/.tmux.conf

See also

  • screen - an alternative to tmux
Personal tools
Namespaces

Variants
Actions
Gentoo Websites logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Navigation
Toolbox
Categories