Created
May 23, 2023 17:27
-
-
Save ryanlane/42dca0141f2a6665dfcb76ed0612dbff to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# List running screen sessions and extract session names | |
screen_list=$(screen -ls | awk '/[0-9]+\.[a-zA-Z0-9_-]+\t/ { print $1 }') | |
# Check if any sessions are running | |
if [[ -z $screen_list ]]; then | |
echo "No screen sessions are currently running." | |
exit 1 | |
fi | |
# Display a menu to select a session | |
echo "Select a screen session to connect:" | |
PS3="Enter your choice: " | |
select session in $screen_list; do | |
if [[ -n $session ]]; then | |
screen -x "$session" # Connect to the selected session | |
break | |
else | |
echo "Invalid choice. Please try again." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you have a lot of screen sessions and don't want to type anything to connect to them then use this handy script