1

I used the tmux.sh example from https://wiki.ubuntuusers.de/tmux/#Bedienung . Now I get a message "sessions should be nested with care, unset $TMUX to force" every time I start 'tmux'. But as I understand, tmux isn't nesting in this case.

My tmux.sh looks as follows now:

#!/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
  • the script looks ok and works fine for me in both cases: when the session exists or even if it doesn't . Are You sure You're not executing the script from a tmux session? – Jakub Jindra Apr 1 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.