升级tmux的起因: 因为使用下面tmux相关维护脚本时,发现1.8.*的版本的tmux在一些参数支持上不到位。 该脚本很多信息保留不全,导致使用效果不好。所以,需要放弃centos自身yum源中的tmux,然后自己手工source.tar.gz进行安装。
脚本参考: https://segmentfault.com/a/1190000000457385#articleHeader0
tmuxEnvSaver.sh
#!/bin/bash
tmuxSnapshot=/.tmux_snapshot
tmuxEXE=/usr/local/bin/tmux
save_snap()
{
${tmuxEXE} list-windows -a -F"#{session_name} #{window_name} #{pane_current_command} #{pane_current_path}" > ${tmuxSnapshot}
}
restore_snap()
{
${tmuxEXE} start-server
while IFS=' ' read -r session_name window_name pane_current_command pane_current_path
do
${tmuxEXE} has-session -t "${session_name}" 2>/dev/null
if [ $? != 0 ]
then
${tmuxEXE} new-session -d -s "${session_name}" -n ${window_name}
else
${tmuxEXE} new-window -d -t ${session_name} -n "${window_name}"
fi
${tmuxEXE} send-keys -t "${session_name}:${window_name}" "cd ${pane_current_path}; echo \"Hint: last time you are executing '${pane_current_command}'.\"" ENTER
done < ${tmuxSnapshot}
}
ps aux|grep -w tmux|grep -v grep
if [ $? != 0 ]
then
restore_snap
else
save_snap
fi
——————————————
crontab
* * * * * echo "`date`: tmuxEnvSaver is running" >> /tmp/cron-tmux.log 2>&1
* * * * * /root/tmuxEnvSaver.sh >> /tmp/cron-tmux.log 2>&1
@reboot /root/tmuxEnvSaver.sh >> /tmp/cron-tmux.log 2>&1
===================
itmux.sh
#!/bin/sh
TMUX="/usr/local/bin/tmux"
$TMUX has-session -t default
if [ $? = 1 ]; then
echo "$TMUX new-session -s default"
$TMUX new-session -s default
else
echo "$TMUX attach-session -d -t default"
$TMUX attach-session -d -t default
fi
前提yum install libevent2
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
git clone https://github.com/tmux/tmux.git
cd tmux
sh autogen.sh
export LIBEVENT_CFLAGS="-I/usr/local/include" export LIBEVENT_LIBS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib -levent"
./configure && make
- http://superuser.com/questions/738829/attempting-to-install-tmux-on-centos-6-x-fails-with-error-evbuffer-eol-lf-und
- https://github.com/tmux/tmux
如果出现 “protocol version mismatch (client 8, server 6)” 类似这样的错误,说明系统中之前存在别的tmux进程是不同的版本的程序生成的,需要先前内存中的tmux进程kill掉。
setw -g mode-keys vi
setw -g aggressive-resize on
setw -g mouse on
开启mouse模式之后,选择文本需要使用shift