前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >tmux-让你完全脱离鼠标的终端神器

tmux-让你完全脱离鼠标的终端神器

作者头像
章鱼喵
发布2018-06-27 15:21:44
1.1K0
发布2018-06-27 15:21:44
举报
文章被收录于专栏:codingcoding

什么是tmux

开发中,经常需要多个任务同时进行,因此需要多个终端标签页,如:一个用于vim编辑器,一个操作数据库,一个操作shell,一个连接远程服务器等。多个终端会话的切换并不方便,也容易分神。而且一断开就得重来。

如果有一种工具,可以在一个终端下完成以上操作,那该多好!

以上的各种困扰,tmux都能做到,而且做得比我们想象的还要更好!

概括来说,tmux就是一个终端复用器(terminal multiplexer)。入门文档请看 tmux: Productive Mouse-Free Development 中文版

以下主要介绍如何安装及配置插件,让tmux更加好用

image.png

安装tmux

环境:ceontos7

tmux版本:2.3

虽然yum源中有tmux,但版本较旧,是1.8版本,在2.1版本后有很大改变,因此还是使用新版的更好

准备工作

代码语言:javascript
复制
# remove old pkgs
yum remove libevent libevent-devel libevent-headers

# install ncurses
yum install ncurses-devel

# download libevent src
cd /usr/local/src
curl -L https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz -o libevent-2.0.21-stable.tar.gz
tar xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure && make
make install
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

安装tmux

代码语言:javascript
复制
cd /usr/local/src
curl -L https://github.com/tmux/tmux/releases/download/2.3/tmux-2.3.tar.gz -o tmux-2.3.tar.gz
tar -xvzf tmux-2.3.tar.gz
cd tmux-2.3
./configure && make
make install

查看tmux

代码语言:javascript
复制
$ which tmux
/usr/local/bin/tmux

$ whereis tmux
tmux: /usr/local/bin/tmux

$ tmux -V
tmux 2.3

插件安装

插件管理器

tmux有专门的插件管理器(2.1版本后才支持),通过插件管理器可以很方便地安装插件,如同vim的vundle一样

插件管理器tpm

安装过程很简单

下载仓库

代码语言:javascript
复制
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

将以下代码粘贴到tmux的配置文件~/.tmux.conf中

代码语言:javascript
复制
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

更新配置

代码语言:javascript
复制
$ tmux source ~/.tmux.conf

其他插件

漂亮的主题

面板快捷键操作

其他配置

tmux默认的PERFIX前缀键是ctrl+b,不好按,可将其改为ctrl+a

以下是我的.tmux.conf内容,供你参考:

代码语言:javascript
复制
set -g prefix C-a 
unbind C-b 
set -sg escape-time 1
set -g base-index 1
setw -g pane-base-index 1
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'seebi/tmux-colors-solarized'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm' 
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.12.02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 什么是tmux
  • 安装tmux
    • 准备工作
      • 安装tmux
        • 查看tmux
        • 插件安装
          • 插件管理器
            • 其他插件
            • 其他配置
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档