Skip to content

Instantly share code, notes, and snippets.

@bhumit070
Created April 21, 2023 05:06
Show Gist options
  • Save bhumit070/14f93fc8cab76674d0c321722d81ecb6 to your computer and use it in GitHub Desktop.
Save bhumit070/14f93fc8cab76674d0c321722d81ecb6 to your computer and use it in GitHub Desktop.
Screen Command
#!/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