tmux使用及配置

  这篇博客跟以前的vim配置一样,都是为了以后本人自己方便备份的tmux配置文件

0.安装

  centos默认自带的软件是screen,没有带tmux,所以需要源代码安装

get clone http://github.com/tmux/tmux.git
cd tmux/
sh autogen.sh
./configure

  这个时候会出错,因为tmux需要libevent环境。而且高版本的tmux需要libevent版本是2.0以上的,而centos6.x通过yum 安装的libevent是1.x版本的,需要卸载后源码安装libevent。

  https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

  编译完libevent后

cd tmux
./configure
make

  这个时候可能会出现错误,通过下面修改

if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
else
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
fi

然后就基本可以了

1.配置

 1 #2015年6月8日 创建配置文件
 2 #文档: http://aquaregia.gitbooks.io/tmux-productive-mouse-free-development_zh/content/
 3 #vim /etc/tmux.conf
 4 #vim ~/.tmux.conf
 5 #PREFIX :   source-file ~/.tmux.conf 使配置生效
 6 
 7 #set --> set-option
 8 #setw --> set-window-option
 9 
10 #定义方便的前缀
11 set -g prefix C-a # -g 选项是全局配置
12 unbind C-b #取消绑定
13 
14 #修改默认延时
15 set -sg escape-time 1
16 
17 #设置窗口和面板的索引
18 set -g base-index 1  #窗口的初始序号;默认为0,这里设置为1
19 setw -g pane-base-index 1
20 
21 #定制新键 虽然这里没有指定PREFIX键,但是实际用的时候还是要的
22 bind r source-file ~/.tmux.conf ; display "Reloaded!"
23 #下面这种方式是可以设置我们使用Ctrl-x来进行,但是这么做,会导致任何程序命令都禁用该组合键,所以要小心
24 #bind-key -n C-x source-file ~/.tmux.conf ; display "ok!"
25 #bind C-x send-prefix  #无效
26 
27 #因为绑定了C-a作为Prefix键,会导致C-a禁用,通过下面方法发送前缀键到其他程序
28 bind C-a send-prefix
29 
30 #分割面板
31 unbind %
32 bind | split-window -h
33 unbind '"'
34 bind - split-window -v
35 
36 #类vim  使用hjkl来移动面板
37 unbind h
38 unbind j
39 unbind k
40 unbind l
41 bind h select-pane -L
42 bind j select-pane -D
43 bind k select-pane -U
44 bind l select-pane -R
45 #定义窗口间循环切换 默认是prefix p/n
46 bind -r C-h select-window -t :-
47 bind -r C-l select-window -t :+
48 #调整面板大小
49 #-r 选项表示该命令可重复使用 如 Prefix H H就是移动10个单位
50 bind -r H resize-pane -L 5
51 bind -r J resize-pane -D 5
52 bind -r K resize-pane -U 5
53 bind -r L resize-pane -R 5
54 #处理鼠标
55 #setw -g mode-mouse on
56 #set -g mouse-select-pane on
57 #set -g mouse-resize-pane on
58 #set -g mouse-select-window on
59 
60 #支持256色
61 set -g default-terminal "screen-256color"
62 set -g status-fg white
63 set -g status-bg black
64 setw -g window-status-fg cyan
65 setw -g window-status-bg default
66 setw -g window-status-attr dim
67 setw -g window-status-current-fg white
68 setw -g window-status-current-bg red
69 setw -g window-status-current-attr bright
70 set -g pane-border-fg green
71 set -g pane-border-bg black
72 set -g pane-active-border-fg white
73 set -g pane-active-border-bg yellow
74 set -g message-fg white
75 set -g message-bg black
76 set -g message-attr bright
77 
78 #配置状态栏
79 set -g status-left-length 40
80 set -g status-left "#[fg=green]Session: #S #[fg=yellow]Window: #I #[fg=cyan]Panel: #P  "
81 set -g status-right "#[fg=cyan]#(date +%H:%M' ')"    #状态栏右方的内容;这里的设置将得到类似23:59的显示
82 set -g status-utf8 on
83 set -g status-interval 30  #每30秒更新一次状态栏
84 set -g status-justify centre #状态栏信息居中
85 
86 #识别其他窗口的活动
87 setw -g monitor-activity on
88 set -g visual-activity on
89 
90 #使用复制模式滚动输出
91 setw -g mode-keys vi
92 
93 #最大化面板
94 unbind Up
95 bind Up new-window -d -n tmp ; swap-pane -s tmp.1 ; select-window -t tmp
96 unbind Down
97 bind Down last-window ; swap-pane -s tmp.1 ; kill-window -t tmp

   用vim+tmux+(任意一种脚本)这三个东西在一起,编程是多么惬意的一件事。基本可以实现0鼠标操作了。 浏览网页时firefox+vimperator ,chrome+vimium (我现在就是用chrome,类似的有很多,chrome的vim插件功能有限,有时候要使用chrome本身的快捷键,慢慢地就熟悉了。) .

  https://blog.linuxeye.com/323.html

  

原文地址:https://www.cnblogs.com/wunaozai/p/4560511.html