tmux是一个优秀的终端复用软件,类似GNU Screen,但来自于OpenBSD,采用BSD授权。使用它最直观的好处就是,通过一个终端登录远程主机并运行tmux后,在其中可以开启多个控制台而无需再“浪费”多余的终端来连接这台远程主机;当然其功能远不止于此。与screen相比的优点:可以横向和纵向分割窗口,且窗格可以自由移动和调整大小。可在多个缓冲区进行复制和粘贴,支持跨窗口搜索;非正常断线后不需重新detach;…… 有人说——与tmux相比,screen简直弱爆了。
下载源码包:
wget --no-check-certificate https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
wget
编译tmux-1.8时,可能出现如下错误:
control.c: In function ‘control_callback’:
control.c:63: warning: implicit declaration of function ‘evbuffer_readln’
control.c:63: error: ‘EVBUFFER_EOL_LF’ undeclared (first use in this function)
control.c:63: error: (Each undeclared identifier is reported only once
control.c:63: error: for each function it appears in.)
control.c:63: warning: assignment makes pointer from integer without a cast
make: *** [control.o] Error 1
原因是使用的libevent的版本太低造成的,tmux1.8要求libevent>= 2.0.10-stable
编译libevent
yum -y install ncurses-devel #依赖包
tar xzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure
make && make install
cd ../
tar xzf tmux-1.8.tar.gz
cd tmux-1.8
CFLAGS="-I/usr/local/include" LDFLAGS="-L//usr/local/lib" ./configure
make && make install1
<strong>直接./configure不能通过编译,报如下错误:</strong>
1cmd-capture-pane.o: In function `cmd_capture_pane_pending':
cmd-capture-pane.c:(.text+0x356): undefined reference to `evbuffer_pullup'
cmd-capture-pane.c:(.text+0x367): undefined reference to `evbuffer_get_length'
cmd-load-buffer.o: In function `cmd_load_buffer_callback':
cmd-load-buffer.c:(.text+0x52): undefined reference to `evbuffer_get_length'
cmd-load-buffer.c:(.text+0x88): undefined reference to `evbuffer_pullup'
cmd-pipe-pane.o: In function `cmd_pipe_pane_exec':
cmd-pipe-pane.c:(.text+0x2bf): undefined reference to `evbuffer_get_length'
cmd-run-shell.o: In function `cmd_run_shell_callback':
cmd-run-shell.c:(.text+0x315): undefined reference to `evbuffer_get_length'
cmd-run-shell.c:(.text+0x3fe): undefined reference to `evbuffer_pullup'
cmd-set-option.o: In function `cmd_set_option_exec':
cmd-set-option.c:(.text+0xc90): undefined reference to `event_initialized'
control.o: In function `control_callback':
control.c:(.text+0x15f): undefined reference to `evbuffer_readln'
control-notify.o: In function `control_notify_input':
control-notify.c:(.text+0x3ef): undefined reference to `evbuffer_pullup'
control-notify.c:(.text+0x3fa): undefined reference to `evbuffer_get_length'
format.o: In function `format_window_pane_tabs':
format.c:(.text+0xe05): undefined reference to `evbuffer_get_length'
format.c:(.text+0xe3b): undefined reference to `evbuffer_pullup'
format.c:(.text+0xe45): undefined reference to `evbuffer_get_length'
input.o: In function `input_set_state':
input.c:(.text+0x1b97): undefined reference to `evbuffer_get_length'
input.o: In function `input_parse':
input.c:(.text+0x1bd8): undefined reference to `evbuffer_get_length'
input.c:(.text+0x1c35): undefined reference to `evbuffer_pullup'
input.c:(.text+0x1c43): undefined reference to `evbuffer_get_length'
job.o: In function `job_write_callback':
job.c:(.text+0x12): undefined reference to `bufferevent_get_output'
job.c:(.text+0x1a): undefined reference to `evbuffer_get_length'
names.o: In function `queue_window_name':
names.c:(.text+0x144): undefined reference to `event_initialized'
names.o: In function `window_name_callback':
names.c:(.text+0x237): undefined reference to `event_initialized'
server-client.o: In function `server_client_check_exit':
server-client.c:(.text+0xbca): undefined reference to `evbuffer_get_length'
server-client.c:(.text+0xbdc): undefined reference to `evbuffer_get_length'
server-client.c:(.text+0xbee): undefined reference to `evbuffer_get_length'
server-client.o: In function `server_client_lost':
server-client.c:(.text+0x1835): undefined reference to `event_initialized'
server-client.c:(.text+0x1859): undefined reference to `event_initialized'
server-client.c:(.text+0x1937): undefined reference to `event_initialized'
server-fn.o: In function `server_update_event':
server-fn.c:(.text+0x23c): undefined reference to `event_initialized'
server-fn.o: In function `server_set_identify':
server-fn.c:(.text+0x2e7): undefined reference to `event_initialized'
server-fn.o: In function `server_push_stdout':
server-fn.c:(.text+0xd9f): undefined reference to `evbuffer_get_length'
server-fn.c:(.text+0xdcc): undefined reference to `evbuffer_pullup'
server-fn.o: In function `server_push_stderr':
server-fn.c:(.text+0xe6b): undefined reference to `evbuffer_get_length'
server-fn.c:(.text+0xe98): undefined reference to `evbuffer_pullup'
server.o: In function `server_add_accept':
server.c:(.text+0x43c): undefined reference to `event_initialized'
status.o: In function `status_message_set':
status.c:(.text+0x2484): undefined reference to `event_initialized'
status.o: In function `status_job_callback':
status.c:(.text+0x25e8): undefined reference to `evbuffer_get_length'
status.c:(.text+0x2623): undefined reference to `evbuffer_pullup'
tty-keys.o: In function `tty_keys_next':
tty-keys.c:(.text+0x6b7): undefined reference to `evbuffer_pullup'
tty-keys.c:(.text+0x6cb): undefined reference to `evbuffer_get_length'
tty-keys.c:(.text+0x771): undefined reference to `event_initialized'
tty-keys.c:(.text+0x843): undefined reference to `event_initialized'
tty-keys.c:(.text+0x8f9): undefined reference to `event_initialized'
tty.o: In function `tty_close':
tty.c:(.text+0x326c): undefined reference to `event_initialized'
window.o: In function `window_pane_read_callback':
window.c:(.text+0x276b): undefined reference to `evbuffer_get_length'
window.c:(.text+0x2791): undefined reference to `evbuffer_get_length'
window.c:(.text+0x27e1): undefined reference to `evbuffer_pullup'
window.o: In function `window_pane_destroy':
window.c:(.text+0x2e5a): undefined reference to `event_initialized'
window.o: In function `window_destroy':
window.c:(.text+0x36c5): undefined reference to `event_initialized'
collect2: ld returned 1 exit status
make: *** [tmux] Error 1