Following one of the comments of one of the responses to this question I've set my default shell to /usr/bin/tmux, which works perfectly fine.

But now I'd like if I could assign all logins to one account to be attached to the same window-group. As per this gist that works by adding new-session -s main to ~/.tmux.conf and then invoking tmux as tmux new-session -t main

Is there a way to have this be invoked as the login shell, or have tmux itself attach to the "main" window-group on launch by default?

  • I find it easier to run a normal shell and use .bashrc or .zshrc to create a new session or attach to an existing one - YMMV – Panki Jun 29 '20 at 12:40
  • And how do I do that? – toman Jun 29 '20 at 14:06
  • Second answer in the question you linked. – Panki Jun 29 '20 at 14:41
if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then
   exec /usr/bin/tmux new-session -t main

Added to the end of my .bashrc seems to do this as I wanted.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.