Sunday, May 4, 2014

0 tmux

tmux is terminal multiplexer. Similar to the screen that I use at office.

Here are few advantages/reasons that using tmux over screen.

  • tmux is under activity development and with BSD license.
  • tmux use less resource.
  • Flexible control the pane.
  • Scroll back history

image


Installation

It is not part of centos yum repository. To install it, we need to set up the EPEL.

yum install tmux

CONFIG:

The user configure tmux configure file is located at ~/.tmux.conf

Here is my binding and below cheat sheet is base on that.

# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50
 
# use UTF8
set -g utf8
set-window-option -g utf8 on
 
# set scrollback history to 100000 (100k)
set -g history-limit 100000
 
# Use something easier to type as the prefix.
set -g prefix C-x
unbind C-b
bind C-x send-prefix
 
# reload config without killing server
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."
 
# Enable auto renaming
setw -g automatic-rename on
 
# rebind the spilt keys
unbind %
bind \ split-window -h
bind - split-window -v
 
# Pane setting
 
bind -n F9 resizep -U 1
bind -n F10 resizep -D 1
bind -n F11 resizep -L 1
bind -n F12 resizep -R 1
 
set-option -g pane-border-fg green
set-option -g pane-border-bg black
 
set-option -g pane-active-border-fg green
set-option -g pane-active-border-bg yellow
 
# pane movement
bind-key j command-prompt -p "join pane from:"  "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:"  "join-pane -t '%%'"
 
# 256 colors please
set -g default-terminal "screen-256color"
 
# colorize messages in the command line
set-option -g message-bg black
set-option -g message-fg brightred
 
# set color for status bar, use prefix + : to enter status command bar
set-option -g status-bg black
set-option -g status-fg yellow #yellow
set-option -g status-attr dim
 
# set window list colors - cyan for inactive
set-window-option -g window-status-fg cyan
set-window-option -g window-status-bg black
set-window-option -g window-status-attr dim
 
# set window list colors - Blue for active
setw -g window-status-current-format '#[bg=red,fg=cyan,bold](#I:#F#W)'
setw window-status-current-attr underscore
 
# Fix putty/pietty function key problem
#set -g terminal-overrides "xterm*:kf1=\e[11~:kf2=\e[12~:kf3=\e[13~:kf4=\e[14~:kf5=\e[15~:kf6=\e[17~:kf7=\e[18~:kf8=\e[19~"
 
# set the status bar message
set -g status-left ' #[bold]#H ⣿'
set -g status-right '#[bold]#(whoami)#(uptime|cut -d "," -f 4-)#[fg=green]%D-%H:%M#[default] '
 
# Activity
setw -g monitor-activity on
set -g visual-activity on
 
 
#
# Mouse Behivor
#
# allow mouse to select which pane to use
set -g mouse-select-pane on
 
# Allow mouse to select windows
set -g mouse-select-window on
 
set-option -g mouse-resize-pane on
set-option -g mouse-select-window on
 
# mouse scroll in tmux -> also go to the copy mode
set -g mode-mouse on
 
set-window-option -g mode-keys vi
unbind [
bind Escape copy-mode
unbind p
# This allow copy vmux buffer to the vi
bind p paste-buffer
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
 
# buffer
bind Space choose-buffer

 

 

Cheat sheet

List tmux session tmux lis
Attached the session tmux a –t <session id>
Kill the current window prefix + &
pane to window prefix + !
next pane prefix + o
next window prefix + n
copy mode prefix + <ESC>
copy to the vmux buffer use mouse select the text  or
copy mode –> prefix + v to select the text –> prefix + y to copy
copy to vi prefix + p
copy from putty to notepad shift key and select as normally putty

putty

This is tricky one. I use putty to my linux box and I like the putty function that can just select the text and copy paste. However, because tumx buffer is independent outside the system buffer and tmux would also take the signal about the putty for the mouse resize. To achieve this goal, we have 2 ways to do it.

1. complete disable the signals from putty .

Terminal –> Features –> Disable xterm-style mouse reporting

By check this box, we can no longer use mouse to resize or pane or enter the copy mode, and copy tmux buffer.

image

2. Press shift key while copy paste

I decided to use the 2nd approach It will take some time to get used to it.

Another challenge is to copy the content of pane into notepad. At this point, I will just move the pane into its own window and use the shift key to do it.

 

 

reference

0 comments:

Post a Comment

 

SQL Panda Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates