后端開發(fā)必備利器:zsh + vim + tmux。下面記錄下以前安裝tmux時遇到的一些問題,之前寫在我的github倉庫上,https://github.com/huchangwei/openresty-study#%E6%BA%90%E7%A0%81%E5%AE%89%E8%A3%85tmux%E9%81%87%E5%88%B0%E7%9A%84%E4%B8%80%E4%BA%9B%E9%97%AE%E9%A2%98,
希望對大家有所幫助。
(1)clone 源代碼倉庫:
$ git clone https://github.com/tmux/tmux.git
(2) 編譯之前先安裝libevent,去官網(wǎng)下載tar包:
http://libevent.org
選擇需要下載的版本復(fù)制鏈接地址,使用wget下載到本地(圖形化的也可以直接下載),如(選擇合適的版本,一般選stable即可):
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
tar -xzf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable/
$ ./configure && make
$ sudo make install
(3) 編譯tmux:
cd tmux/
sh autogen.sh
./configure && make
安裝編譯過程可能會提示一些錯誤:
1)aclocal command not found
原因:自動編譯工具未安裝,安裝上即可:
centOS: yum install automake
- configure: error: "curses or ncurses not found"
ubuntu:apt-get install libncurses5-dev
centos: yum install ncurses-devel
(4) 編譯成功之后會在tmux下生成一個可執(zhí)行程序:tmux
./tmux
執(zhí)行的時候可能會出現(xiàn)找不到庫的情況:
./tmux: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
把安裝好的libevent庫的路徑使用軟鏈接到對應(yīng)的目錄:
64位:
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
32位:
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
(5)設(shè)置環(huán)境變量
現(xiàn)在使用tmux必須在編譯好的目錄下執(zhí)行才可以,我們設(shè)置個環(huán)境變量即可:
ln -s /home/hcw/Package/tmux/tmux /usr/bin/
/home/hcw/Package/tmux/ 為你編譯好的路徑,因為/usr/bin/已經(jīng)添加到系統(tǒng)環(huán)境變量,所以不需要再設(shè)置,如此即可使用tmux
(6)下面是我常用的tmux配置:
wget https://github.com/huchangwei/dotfiles/raw/master/.tmux.conf -P ~
其中需要用到插件管理,需要先安裝插件管理器:
https://github.com/tmux-plugins/tpm
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
在.tmux.conf添加:(如果你是使用我的配置,下面可以省略)
#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'
Reload TMUX environment so TPM is sourced:
# type this in terminal
$ tmux source ~/.tmux.conf
最后看看效果:

t1.png