Created
November 3, 2024 14:47
-
-
Save noflcl/119cccac5d51bd799e2d903e7daf8329 to your computer and use it in GitHub Desktop.
tmux launch new windows under "trunk" session starting at branch0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ! [ "$(tmux ls | cut -d: -f1)" = "trunk" ]; then | |
tmux new-session -d -s trunk -n branch0 | |
tmux attach-session -t trunk:branch0 | |
elif [[ -z "${TMUX}" ]]; then | |
branch_id="$(tmux ls | cut -d ' ' -f2)" | |
tmux new-window -d -n branch$branch_id -t trunk: | |
tmux attach-session -t trunk:$branch_id | |
else | |
branch_id="$(tmux ls | cut -d ' ' -f2)" | |
tmux new-window -n branch$branch_id -t trunk: | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bash
script its 95% correct. You call the script and it spawns a new window under the "trunk" session and increments the brach"id" (branch0, branch1, branch2) but keeps you in the window that you are working in (this is key). If you are not in the same terminal (not in a tmux sessions) and you launch the script it creates the new branch and attaches you to that one.The issue is, the terminal that was active on the previous window doing work (maybe doing work in the quake drop down terminal - completely separate terminal application) is now also switched to the new branch and they are mirrored since they are connected to the same session.