Created
July 5, 2025 06:12
-
-
Save Rajesh-Royal/128a0fb2429297870da62a55914118e4 to your computer and use it in GitHub Desktop.
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 Dev Servers in Tabs with a Single Script* | |
| #### π Overview | |
| This Bash script helps developers launch multiple development projects (like frontend, backend, dashboard) in separate **GNOME Terminal tabs** with just one command. | |
| It includes: | |
| * A **preview** of what will run. | |
| * A **confirmation prompt** before execution. | |
| * Colorful, readable terminal output. | |
| * A final success message. | |
| --- | |
| #### π οΈ Use Case | |
| Great for monorepos or workspaces where you frequently run multiple dev environments: | |
| * Frontend: `npm run dev` | |
| * Backend: `npm run dev` | |
| * Admin Panel: `npm run dev` | |
| --- | |
| #### π Directory Structure (Example) | |
| ``` | |
| your-projects/ | |
| βββ backend/ | |
| βββ frontend/ | |
| βββ admin-dashboard/ | |
| ``` | |
| --- | |
| #### π Script: `start-projects.sh` | |
| ```bash | |
| #!/usr/bin/env bash | |
| # Define folder names | |
| FOLDERS=("backend" "frontend" "admin-dashboard") | |
| # Define tab titles | |
| TITLES=("Backend" "Frontend" "Admin Dashboard") | |
| # Define colors | |
| GREEN='\033[0;32m' | |
| CYAN='\033[0;36m' | |
| YELLOW='\033[1;33m' | |
| RESET='\033[0m' | |
| # Preview the commands to be executed | |
| echo -e "${CYAN}This command will execute the following scripts:${RESET}" | |
| for i in "${!FOLDERS[@]}"; do | |
| echo -e "- ${YELLOW}Tab Title${i}: ${TITLES[i]}${RESET}: cd ${FOLDERS[i]} && npm run dev" | |
| done | |
| # Ask for confirmation | |
| echo -e "\n${GREEN}Do you want to continue? Press Enter to continue or Ctrl+C to cancel...${RESET}" | |
| read | |
| # Launch terminal tabs | |
| gnome-terminal --tab --title="${TITLES[0]}" -- bash -c "cd '${FOLDERS[0]}' && npm run dev; exec bash" & | |
| gnome-terminal --tab --title="${TITLES[1]}" -- bash -c "cd '${FOLDERS[1]}' && npm run dev; exec bash" & | |
| gnome-terminal --tab --title="${TITLES[2]}" -- bash -c "cd '${FOLDERS[2]}' && npm run dev; exec bash" & | |
| # Wait a moment for terminals to launch | |
| sleep 1 | |
| # Final message | |
| echo -e "\n${GREEN}βοΈ Scripts launched successfully!${RESET}" | |
| ``` | |
| --- | |
| #### π¦ How to Use | |
| 1. Place this script in the root directory of your projects. | |
| 2. Make it executable: | |
| ```bash | |
| chmod +x start-projects.sh | |
| ``` | |
| 3. Run it: | |
| ```bash | |
| ./start-projects.sh | |
| ``` | |
| --- | |
| #### π‘ Notes | |
| * Designed for GNOME Terminal (Ubuntu default). | |
| * Adjust `FOLDERS` and `TITLES` to match your project structure. | |
| * You can add more tabs by extending the arrays and launch commands. | |
| Twitter: @Raj_896 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a working script; I use it daily for my local development. I need to start backend, frontend, and identity access management projects one by one, so I created this script to launch all of them at once.

