Skip to content

Instantly share code, notes, and snippets.

@jfly
Last active August 23, 2017 05:54
Show Gist options
  • Save jfly/7b94cba17c04d344d62a7bea916bb55a to your computer and use it in GitHub Desktop.
Save jfly/7b94cba17c04d344d62a7bea916bb55a to your computer and use it in GitHub Desktop.
bash function to start a screen session with multiple named windows running specified commands
function start_screen {
NAME=$1
shift
screen -dmS "$NAME" -s bash # start screen
while test $# -gt 0
do
TITLE="$1"
shift
CMD="$1"$'\n'
shift
screen -S "$NAME" -X title "$TITLE" # set title of window
screen -S "$NAME" -X stuff "$CMD" # run command in window
screen -S "$NAME" -X screen # add new window
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment