您的位置:首页 > 其它

tmux使用及配置

2015-06-17 19:23 295 查看
  这篇博客跟以前的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.配置

#2015年6月8日 创建配置文件
#文档: http://aquaregia.gitbooks.io/tmux-productive-mouse-free-development_zh/content/ #vim /etc/tmux.conf
#vim ~/.tmux.conf
#PREFIX :   source-file ~/.tmux.conf 使配置生效

#set --> set-option
#setw --> set-window-option

#定义方便的前缀
set -g prefix C-a # -g 选项是全局配置
unbind C-b #取消绑定

#修改默认延时
set -sg escape-time 1

#设置窗口和面板的索引
set -g base-index 1  #窗口的初始序号;默认为0,这里设置为1
setw -g pane-base-index 1

#定制新键 虽然这里没有指定PREFIX键,但是实际用的时候还是要的
bind r source-file ~/.tmux.conf \; display "Reloaded!"
#下面这种方式是可以设置我们使用Ctrl-x来进行,但是这么做,会导致任何程序命令都禁用该组合键,所以要小心
#bind-key -n C-x source-file ~/.tmux.conf \; display "ok!"
#bind C-x send-prefix  #无效

#因为绑定了C-a作为Prefix键,会导致C-a禁用,通过下面方法发送前缀键到其他程序
bind C-a send-prefix

#分割面板
unbind %
bind | split-window -h
unbind '"'
bind - split-window -v

#类vim  使用hjkl来移动面板
unbind h
unbind j
unbind k
unbind l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
#定义窗口间循环切换 默认是prefix p/n
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
#调整面板大小
#-r 选项表示该命令可重复使用 如 Prefix H H就是移动10个单位
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
#处理鼠标
#setw -g mode-mouse on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
#set -g mouse-select-window on

#支持256色
set -g default-terminal "screen-256color"
set -g status-fg white
set -g status-bg black
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 pane-border-fg green
set -g pane-border-bg black
set -g pane-active-border-fg white
set -g pane-active-border-bg yellow
set -g message-fg white
set -g message-bg black
set -g message-attr bright

#配置状态栏
set -g status-left-length 40
set -g status-left "#[fg=green]Session: #S #[fg=yellow]Window: #I #[fg=cyan]Panel: #P  "
set -g status-right "#[fg=cyan]#(date +%H:%M' ')"    #状态栏右方的内容;这里的设置将得到类似23:59的显示
set -g status-utf8 on
set -g status-interval 30  #每30秒更新一次状态栏
set -g status-justify centre #状态栏信息居中

#识别其他窗口的活动
setw -g monitor-activity on
set -g visual-activity on

#使用复制模式滚动输出
setw -g mode-keys vi

#最大化面板
unbind Up
bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
unbind Down
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

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: