Wednesday, August 8, 2012

putty + tmux 结合实现命令行多窗口

最近要远程登录Linux系统做一些东西,用putty一次 只能够执行一个程序,要在不同的目录运行不同的东西,要打开几个putty,很是麻烦。Google了一下,找到tmux这个小程序,参考了别人的配置,自己稍加改动,现在使用起来真的很爽。

我的配置文件:

##########################################################
# STATUS BAR
set -g status-utf8 on
set -g status-key vi
set -g status-interval 1
set -g status-attr bright
set -g status-fg white
set -g status-bg black
set -g status-left-length 20
set -g status-left '#[fg=green][#[fg=red]#S#[fg=green]]#[default]'
set -g status-justify centre
set -g status-right '#[fg=green][%m/%d %H:%M:%S]#[default]'
setw -g window-status-current-format '#[fg=yellow](#I.#P#F#W)#[default]'
setw -g window-status-format '#I#F#W'


##########################################
## TERMINAL EMULATOR TITLES
set -g set-titles on
set -g set-titles-string "#(tmux ls | awk -F: '{print $1}' | xargs | sed 's/\ / | /g')"


##########################################
## KEy BINDINGS
unbind C-b
set -g prefix C-s

# - = vertical split
unbind '"'
bind - split-window -v

# | = horizontal split
unbind %
bind \ split-window -h

# VIM Style movement
bind k selectp -U   # choose top panel
bind j selectp -D   # choose bottom panel
bind h selectp -L   # choose left panel
bind l selectp -R   # choose right panel

# bind ALT+Arrow to select panel
bind -n M-Up selectp -U   # choose top panel
bind -n M-Down selectp -D   # choose bottom panel
bind -n M-Left selectp -L   # choose left panel
bind -n M-Right selectp -R   # choose right panel


# Keys for resize panel
bind -n F9 resizep -U 1   # up
bind -n F10 resizep -D 1  # down
bind -n F11 resizep -L 1  # left
bind -n F12 resizep -R 1  # right

##########################################
## BASIC CONFIG
## utf8 ability
setw -g utf8 on
#
## vi Style Editing
setw -g mode-keys vi
#
## Make mouse useful in copy mode
#setw -g mode-mouse on

#
## Allow mouse to select which pane to use
#set -g mouse-select-pane on
#
## Allow xterm titles in terminal window, terminal scrolling with scrollbar, and setting overrides of C-Up, C-Down, C-Left, C-Right
set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
#
## Scroll History
set -g history-limit 30000
#
## Set ability to capture on start and restore on exit window data when running an application
setw -g alternate-screen on
#
## Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50

No comments: