Created
January 26, 2017 14:01
-
-
Save fabrizioq/862e4b8465716bf09b8bd84d92bab5e0 to your computer and use it in GitHub Desktop.
Script to create screen ssession w/ named windows
This file contains hidden or 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 | |
MINPARAMS=2 | |
if [ $# -lt "$MINPARAMS" ] | |
then | |
echo | |
echo "Scrnr needs at least $MINPARAMS command-line arguments!" | |
exit 1 | |
fi | |
declare -A common | |
common["git"]="tig" | |
common["vim"]="vim ." | |
common["irb"]="irb" | |
common["console"]="./bin/rails c" | |
common["webpack"]="webpack --watch" | |
common["node"]="node" | |
common["psql"]="psql" | |
screen -AmdS $1 | |
numargs=$# | |
for ((i=2 ; i <= numargs ; i++)) | |
do | |
screen -S $1 -p 0 -X screen -t ${!i} | |
if [[ ${common[${!i}]} ]]; | |
then | |
window=$(( i - 1 )) | |
screen -S $1 -p $window -X stuff "${common[${!i}]} | |
" | |
sleep 0.5; echo -n . | |
fi | |
done | |
screen -S $1 -p 0 -X kill | |
screen -x $1 -p 1 | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment