Skip to content

Instantly share code, notes, and snippets.

@Rajesh-Royal
Created July 5, 2025 06:12
Show Gist options
  • Save Rajesh-Royal/128a0fb2429297870da62a55914118e4 to your computer and use it in GitHub Desktop.
Save Rajesh-Royal/128a0fb2429297870da62a55914118e4 to your computer and use it in GitHub Desktop.
### πŸ“„ *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
@Rajesh-Royal
Copy link
Author

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.
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment