Created
July 10, 2024 21:03
-
-
Save Rayquaza01/073632ef803cfd639406f72d842224fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| # if inside a tmux session, don't do anything | |
| if [ -z "$TMUX" ]; then | |
| # get the session name of the first session that isn't attached | |
| FREE_SESSION=$(tmux ls 2>/dev/null | grep -v "(attached)$" | cut -f1 -d: | head -n 1) | |
| # if no free sessions, make a new one | |
| # otherwise attach to it | |
| if [ -z "$FREE_SESSION" ]; then | |
| tmux new && exit | |
| else | |
| tmux attach -t "$FREE_SESSION" && exit | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment