
tmux.sh 예제를 사용했습니다.https://wiki.ubuntuusers.de/tmux/#Bedienung. 이제 "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
답변1
스크립트 시작 부분에 다음을 추가하면 다음과 같은 오류를 방지할 수 있습니다.
# If script is run inside tmux, exit without doing anything
if [[ -n $TMUX ]]; then
echo "Nested tmux sessions not supported!"
exit 0
fi