Created
April 21, 2023 05:06
-
-
Save bhumit070/14f93fc8cab76674d0c321722d81ecb6 to your computer and use it in GitHub Desktop.
Screen Command
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 | |
function ss() { | |
local screenName="$1" | |
if [ -z "$screenName" ]; then | |
echo "No service name provided." | |
exit 1 | |
fi | |
local isScreenRunning=$(screen -ls | grep -ciw "$screenName") | |
echo "isScreenRunning: $isScreenRunning" | |
if [ "$isScreenRunning" -eq 0 ]; then | |
echo "Screen is not running." | |
screen -S "$screenName" | |
exit 0 | |
else | |
screen -dR "$screenName" | |
fi | |
} | |
# pass all the arguments to the function from stdin | |
ss "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment