Created
August 6, 2025 09:16
-
-
Save madalinpopa/08877b439fc5a5122cdb224b512387c4 to your computer and use it in GitHub Desktop.
Start the tmux session if not already in the tmux session
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
| # Start the tmux session if not already in the tmux session | |
| if [[ -z $TMUX ]]; then | |
| mapfile -t sessions < <(tmux list-sessions -F "#S" 2>/dev/null) | |
| choices=("${sessions[@]}" "Create new session" "Start without tmux") | |
| choice=$(printf "%s\n" "${choices[@]}" | sk --margin 10% --color='bw') | |
| if [[ " ${sessions[*]} " == *" $choice "* ]]; then | |
| tmux attach-session -t "$choice" | |
| elif [[ "$choice" == "Create new session" ]]; then | |
| tmux new-session | |
| fi | |
| # Else do nothing (start without tmux) | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment