源碼安裝tmux遇到的一些問題

后端開發(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
  1. 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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容