我使用了来自https://wiki.ubuntuusers.de/tmux/#Bedienung的C0示例。现在,我收到一条消息:每次启动'tmux‘时,“会话都应该嵌套,未设置$TMUX强制”。但据我所知,在这种情况下,tmux不是嵌套的。
我的tmux.sh现在看起来如下:
#!/bin/bash
SESSION=main
#tmux="tmux -2 -f ~/.tmux.conf"
tmux="tmux -2"
# if the session is already running, just attach to it.
$tmux has-session -t $SESSION
if [ $? -eq 0 ]; then
# echo "Session $SESSION already exists. Attaching."
sleep 1
$tmux attach -t $SESSION
exit 0;
else
# create a new session, named $SESSION, and detach from it
$tmux new-session -n Werkbank -d -s $SESSION
$tmux split-window -h -t $SESSION:1
$tmux new-window -n "SysA|SysB" -t $SESSION:2 'ssh A'
$tmux split-window -h -t $SESSION:2 'ssh B'
$tmux new-window -n "GwA|GwB" -t $SESSION:3
$tmux split-window -h -t $SESSION:3
$tmux select-window -t $SESSION:1
$tmux attach -t $SESSION
fi发布于 2020-04-14 16:22:55
在脚本的开头添加以下内容可以防止此类错误:
# If script is run inside tmux, exit without doing anything
if [[ -n $TMUX ]]; then
echo "Nested tmux sessions not supported!"
exit 0
fihttps://unix.stackexchange.com/questions/509848
复制相似问题