Created
July 18, 2011 02:32
-
-
Save Ruxton/1088435 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
# __screend: screen daemonizing | |
__screend() { | |
local name="${1}" | |
local check=`screen -list|grep $name|awk '{print $1}'` | |
if [[ "$2" = "" ]]; then | |
if [[ "${check}" = "" ]]; then | |
screen -dmS $name $name > /dev/null | |
local runCheck=`screen -list|grep $name|awk '{print $1}'` | |
if [[ "${runCheck}" = "" ]]; then | |
echo "Unable to start ${name} in background" | |
else | |
echo "Started ${name} in background" | |
fi | |
else | |
echo "${name} is running in background..." | |
read -ep "re-attach? (y/n)" choice | |
if [[ $choice = [yY] ]]; then | |
echo "Attaching ${name} session..." | |
screen -r $check | |
else | |
echo "${name} currently running at ${check}" | |
fi | |
fi | |
else | |
if [[ $2 -eq "load" ]]; then | |
screen -r $name | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment