【转载】Screen与Tmux的使用

因为Tmux可分屏,且定制性高,自己在服务器端安装了Tmux。经常使用Tmux操作,末尾附上自己的配置。

不过,大部分服务器只有screen,因此,也转载一篇screen的命令使用。

Linux下终端利器tmux

linux screen 命令详解

自己的tmux配置文件~/.tmux.conf

set -g default-terminal "screen-256color"
set -g display-time 3000
set -g escape-time 0
set -g history-limit 65535
set -g base-index 1
set -g pane-base-index 1

#-- bindkeys --#
# prefix key (Ctrl+a)
set -g prefix ^a
unbind ^b
bind a send-prefix

# split window
unbind '"'
# vertical split (prefix -)
bind - splitw -v
unbind %
bind | splitw -h # horizontal split (prefix |)

# select pane
bind k selectp -U # above (prefix k)
bind j selectp -D # below (prefix j)
bind h selectp -L # left (prefix h)
bind l selectp -R # right (prefix l)

# resize pane
bind -r ^k resizep -U 10 # upward (prefix Ctrl+k)
bind -r ^j resizep -D 10 # downward (prefix Ctrl+j)
bind -r ^h resizep -L 10 # to the left (prefix Ctrl+h)
bind -r ^l resizep -R 10 # to the right (prefix Ctrl+l)

# swap pane
# swap with the previous pane (prefix Ctrl+u)
bind ^u swapp -U
# swap with the next pane (prefix Ctrl+d)
bind ^d swapp -D

# misc
# select the last pane (prefix e)
bind e lastp
# select the last window (prefix Ctrl+e)
bind ^e last
# kill pane (prefix q)
bind q killp
# kill window (prefix Ctrl+q)
bind ^q killw

# copy mode
# enter copy mode (prefix Escape)
bind Escape copy-mode
# paste buffer (prefix Ctrl+p)
bind ^p pasteb
# select (v)
bind -t vi-copy v begin-selection
# copy (y)
bind -t vi-copy y copy-selection

# zoom pane <-> window
#http://tmux.svn.sourceforge.net/viewvc/tmux/trunk/examples/tmux-zoom.sh
#bind ^z run "tmux-zoom"

# app
# htop (prefix !)
#bind ! splitw htop
# man (prefix m)
bind m command-prompt "splitw 'exec man %%'"

# reload config (prefix r)
bind r source ~/.tmux.conf \; display "Configuration reloaded!"

setw -g mode-keys vi
setw -g automatic-rename on

#-- colorscheme --#
#https://github.com/daethorian/conf-tmux/blob/master/colors/zenburn.conf

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

#pane
set -g pane-border-fg white
set -g pane-border-bg black
set -g pane-active-border-fg green
set -g pane-active-border-bg black

# Set status bar
set -g status-justify centre
set -g status-utf8 on
set -g status-fg white
set -g status-bg colour237
setw -g window-status-fg cyan
setw -g window-status-bg default
setw -g window-status-attr dim
setw -g window-status-current-fg white
setw -g window-status-current-bg red
#setw -g window-status-current-attr bright

set -g status-left '#[fg=green][#S]:#I:#P'
set -g status-right '#[fg=yellow]#(uptime | egrep -o "[0-9]+ users?, +load.*"|perl -pe "s| averages?||"), %H:%M'
set -g status-right-length 50

# messages
set -g message-attr bold
set -g message-fg colour223
set -g message-bg colour235
set -g visual-activity on
setw -g monitor-activity on