dongjun111111 / blog

BLOG
36 stars 5 forks source link

Screen/Tmux #36

Open dongjun111111 opened 8 years ago

dongjun111111 commented 8 years ago

Screen/Tmux

screen/tmux 是远程ssh session的管理工具。 可以在server端帮你保存工作现场和恢复工作现场。 最典型的应用场景就是,你每天下班关机器的时候,先保存现场(session)。 然后第二天上班的时候再登录上去恢复现场(session) ,可以一下子就进入到之前的工作状态, 比如当时正使用vim编写代码编写到第N行的状态。 .screenrc 配置文件:

hardstatus alwayslastline  
hardstatus string "%{.bW}%-w%{.rY}%n %t%{-}%+w %=%{..G} %c:%s "  
startup_message off  
vbell off  
bind ' ' title 
bindkey -k k; title
bindkey -k F1 prev
bindkey -k F2 next
#defencoding GBK
#encoding GBK UTF-8

bindkey "^[j" prev
bindkey "^[k" next

tmux是screen的增强版。 .tmux.conf 配置文件:

set -g prefix ^a
unbind ^b
bind a send-prefix

#set -g status-right "#[fg=green]#(uptime.pl)#[default] . #[fg=green]#(cut -d ' ' -f 1-3 /proc/loadavg)#[default]"
set -g status-right '%H:%M:%S %d-%b-%y'

set -g status-bg blue
set -g status-fg yellow

setw -g window-status-current-fg white  
setw -g window-status-current-bg red  
setw -g window-status-current-attr bright

# -n means no prefix
bind-key -n F7 command-prompt 'rename-session %%'
bind-key -n F10 command-prompt 'rename-window %%'
bind-key -n F11 previous-window
bind-key -n F12 next-window

参考

http://yanyiwu.com/work/2016/03/24/from-screen-to-tmux.html