Starting a Development Environment from the Command Line
I have a need for speed when developing. That goes for starting up all of my development applications.
Here's what needs to happen before I start coding:
- Open my repo in VS Code
- Load in any environment variables
- Start the local server
- Open up chrome
- Visit localhost:3000
A short list. But it takes a few key strokes and mouse clicks to get there. I think I can do better!
Linux Alias Commands are the answer.
I have a few set up for a few different use cases. Here's the one the runs the recipe for the steps above:
alias cap="cd /Users/cpadilla/code/my-repo && code . && open http://localhost:3000 && source settings.sh && npm run dev
I'm adding this to my .zshrc file at the root of my account.
That turns all five steps into one:
Another use case: I keep a list of todos in markdown on my computer. Files are named by the current date. I could do it by hand every time, but there's a better way:
alias dsmd="touch $(date +%F).md && open $(date +%F).md" alias todo="cd /Users/cpadilla/Documents/Todos && dsmd"
There we go!
$(date +%F) is a command for delivering a specific date format. The
todo alias navigates to the correct folder and then uses
dsmd to create and open the file.
Small quality of life changes! They add up when you do the same commands every day. 🙂