Created
November 30, 2017 06:46
-
-
Save ltfschoen/eaabbb402e6818edc3a58f07cdc17ee7 to your computer and use it in GitHub Desktop.
Launch multiple bash terminal tab windows with one command
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
| # Launch multiple bash terminal tab windows by running the command `bash launch.sh` | |
| #!/bin/bash | |
| # File: ~/launch.sh | |
| # Original Code Reference: http://dan.doezema.com/2013/04/programmatically-create-title-tabs-within-the-mac-os-x-terminal-app/ | |
| # New-BSD License by Original Author Daniel Doezema http://dan.doezema.com/licenses/new-bsd/ | |
| # Modified by Luke Schoen in 2017 to include loading new tabs such as client and server and automatically open webpage in browser. | |
| function new_tab() { | |
| TAB_NAME=$1 | |
| DELAY=$2 | |
| COMMAND=$3 | |
| osascript \ | |
| -e "tell application \"Terminal\"" \ | |
| -e "tell application \"System Events\" to keystroke \"t\" using {command down}" \ | |
| -e "do script \"$DELAY; printf '\\\e]1;$TAB_NAME\\\a'; $COMMAND\" in front window" \ | |
| -e "end tell" > /dev/null | |
| } | |
| # atom ~/code/apps/myapp_client ~/code/apps/myapp_server | |
| # Create new tabs to load the servers and show logs. | |
| Wait for Mongo, Redis, and Elasticsearch to load | |
| new_tab "Elasticsearch Tab" \ | |
| "echo 'Loading Elasticsearch...'" \ | |
| "elasticsearch" | |
| new_tab "Redis Tab" \ | |
| "echo 'Loading Redis...'" \ | |
| "redis-server /usr/local/etc/redis.conf" | |
| new_tab "Mongo Tab" \ | |
| "echo 'Loading Mongo...'" \ | |
| "mongod --dbpath /usr/local/var/mongodb" | |
| new_tab "Myapp Server Tab" \ | |
| "echo 'Waiting for Elasticsearch, Redis, and Mongo to load...'; sleep 10" \ | |
| "cd ~/code/apps/myapp_server; npm run dev;" | |
| # new_tab "Myapp Server Cron Tab" \ | |
| # "echo 'Waiting for Elasticsearch, Redis, and Mongo to load...'; sleep 10" \ | |
| # "cd ~/code/apps/myapp_server; npm run cron-dev;" | |
| # Create new tab to load the client. | |
| # Wait for Server and dependencies then open web server in browser | |
| new_tab "Myapp Client Browser Tab" \ | |
| "echo 'Waiting for Myapp Server and dependencies...'; sleep 15" \ | |
| "cd ~/code/apps/myapp_client; npm run dev; sleep 15" \ | |
| "open http://localhost:3000;" | |
| # Create new tab to load the client. | |
| # Wait for Server and dependencies then open web server in browser | |
| new_tab "Myapp Files Tab" \ | |
| "cd '/Users/Myusername/Google Drive/To Sync/Myapp'; atom ." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment