I'm using zsh and byobu (using the tmux backend).
In my .zshrc
file I put the following:
if which byobu >/dev/null 2>&1; then
# if not inside a byobu session, and if no session is started,
# start a new session
test -z "$TMUX" && (byobu attach || byobu new-session)
fi
If I close the terminal emulator I'm using, then open another one, I re-attach to the byobu session I was using and all is fine. However, when I just start my computer, or if I exited byobu (for example by pressing Ctrl-D
on the last open window), opening a new terminal results in this:
[exited]
~$
It seems to be because byobu attach
actually returns something, so byobu new-session
is never run, but I don't understand why byobu attach
finds something if I quit byobu (in this case, $TMUX
is empty).
How can I make sure that a new session of byobu is launched if there is no instance already running?
Thanks!