Search code examples
tmuxbyobu

Byobu tmux - How to open a new window in an existing session by name?


To enter a session:

byobu attach -t "session name"

Open a tab in the current session:

byobu new-window "bash"

Open a tab in a new session (if session doesn't exist):

byobu new-session -d -s "session name" "bash"

But how to open a new-window in an existing session by calling its name?


Solution

  • I had the same problem and found the solution by using the -t "session name" param when creating new byobu windows.

    Example of my script that also restarts several processes and thus must first kill all the previous processes (in the previous session). The first process starts a new (detached -d) session with a specific $SESSION_NAME name, later processes only start a new window attaching to the $SESSION_NAME session. I also name my windows, that's what the -n param is for:

    SESSION_NAME="Session 1"
    
    echo "Killing possible previous byobu session '$SESSION_NAME'"
    byobu kill-session -t $SESSION_NAME
    
    echo "Starting new byobu session: $SESSION_NAME"
    
    echo "Starting process 1..."
    byobu new-session -d -s "$SESSION_NAME" -n "Proc 1" "run 1..."
    
    echo "Starting process 2..."
    byobu new-window -t "$SESSION_NAME" -n "Proc 2" "run 2..."
    echo "Starting process 3..."
    byobu new-window -t "$SESSION_NAME" -n "Proc 3" "run 3..."
    ...