How to Quickly Launch Your Development Environment with a Single Command
Introduction
Setting up your development environment every time you start working can be tedious. Instead of manually opening browser windows for different sites, you can automate the process with a simple Bash script. In this guide, I’ll show you how to launch your local development server and other essential sites in one command.
Prerequisites
- WSL (Windows Subsystem for Linux) if you are using Windows
- Brave Browser (or Chrome) installed
- Bash scripting knowledge (optional, but useful)
The Script
Here's a simple Bash script to launch your local development site and other essential resources:
#!/bin/bash
"/mnt/c/Users/USERNAMEHERE/AppData/Local/BraveSoftware/Brave-Browser/Application/brave.exe" --new-window "http://localhost:3000"
"/mnt/c/Users/USERNAMEHERE/AppData/Local/BraveSoftware/Brave-Browser/Application/brave.exe" "https://vercel.com/"
"/mnt/c/Users/USERNAMEHERE/AppData/Local/BraveSoftware/Brave-Browser/Application/brave.exe" "https://react-icons.github.io/react-icons/"
Explanation
- The script uses the
brave.exebinary to open URLs. - The first command opens the local development environment in a new window.
- The subsequent commands open commonly used resources in separate tabs.
- This works on Linux and macOS too—you just need to replace the file path to Brave or Chrome accordingly.
Running the Script
- Save the script as
launch_dev.sh. - Give it execute permissions:
chmod +x launch_dev.sh - Run it with:
./launch_dev.sh
Creating an Alias for Quick Access
To make this even faster, you can create an alias:
- Open your
~/.bashrc(or~/.zshrcif using Zsh):nano ~/.bashrc - Add the following line at the end:
alias devstart='/path/to/launch_dev.sh' - Save and exit (
CTRL + X, thenY, thenENTER). - Apply changes:
source ~/.bashrc - Now, you can start everything with:
devstart
Adding the Alias to package.json
If you're using yarn dev or npm run dev to start your development server, you can modify your package.json to include the alias so everything launches with a single command.
- Open your
package.jsonfile. - Find the
scriptssection and modify thedevcommand like this:"scripts": { "dev": "./launch_dev.sh & next dev" } - Now, when you run:
oryarn dev
it will open your local development site and other resources automatically.npm run dev
Conclusion
Using a simple Bash script and an alias, you can launch your entire development environment with a single command. This saves time and ensures consistency every time you start working. Adapt the script for your own workflow by adding more URLs or tweaking browser options.