DEV Community

Cover image for One bash command to start the day 🌅
Doaa Mahely
Doaa Mahely

Posted on

One bash command to start the day 🌅

When I first started at my current job, I was using my personal laptop. Being a stickler for the separation between work-time and non-work-time, I would routinely open GitLab, ClickUp, Slack, Localhost, MAMP and VS Code in the morning and promptly close all those windows come 6 o'clock. I did this manually every day for weeks.

Eventually, I decided to write something that I can run once so that everything I needed open will open quickly.

1. Opening links in Safari

I wrote a Python script that uses the webbrowser module to open the websites I needed. It looks like this

import webbrowser

websites = [

for website in websites:
Enter fullscreen mode Exit fullscreen mode

Note: the webbrowser module will open the provided links with the default browser

2. Opening MAMP

I use MAMP to start my local server and database. I'm able to do this from the command line by using this snippet cd /Applications/MAMP/bin && ./ Make sure to substitute the path for MAMP for its path on your machine. I aliased this command in my bash_profile file with the alias startm. Now in my terminal I can run startm and the MAMP server will start. This also saves me some space in my Dock because having too many icons at the bottom stresses me out. Alternatively, to close the server I use stopm which is aliased to cd /Applications/MAMP/bin && ./

# .bash_profile
alias startm='cd /Applications/MAMP/bin && ./'
alias stopm='cd /Applications/MAMP/bin && ./'
Enter fullscreen mode Exit fullscreen mode

3. Opening VS Code

VS Code has a command line utility that allows us to launch it with the working directory right from the terminal. To make sure this utility is running, open the Command Palette on Code by clicking on ⇧⌘P on a Mac, and search for 'shell'. Then, click on "Shell Command: Install 'code' command in PATH" and the code utility will be available.

Installing the code utility on VS Code

Note: this may require restarting the terminal

4. Navigating to different projects

I work on a couple of different projects on a given day, so I have aliases for quickly cd'ing into those directories. You can choose the appropriate names as you see fit.

# .bash_profile
alias project1='cd /projects/project1'
Enter fullscreen mode Exit fullscreen mode

Here, we can even go further and couple this command with the code command which will navigate us into the project's package and launch it on Code. This would look like this:

# .bash_profile
alias project1='cd /projects/project1 && code .'
Enter fullscreen mode Exit fullscreen mode

5. Putting it all together in one command

Now that I set up my .bash_profile and made sure the code utility is installed, I aliased one more command that will allow me to prep for the work day in four letters:

# .bash_profile
alias work='python ~/ && startm && project1'
Enter fullscreen mode Exit fullscreen mode

So now I just type work into my terminal, go to get myself a coffee then sit down to start the day. What programs or websites would you substitute for your workflow?

Thank you for reading. Let me know how I can make this article better. Until next time 👋

Cover photo by Sara Codair on Unsplash.

Top comments (22)

didacsf profile image
Dídac Sementé Fernández

One thing I do in my own laptop is make a separate account for my work user and another one for my personal user. That way I don't need to worry about one thing interfering with the other.

dmahely profile image
Doaa Mahely

That's a good idea as well

bogdaaamn profile image
Bogdan Covrig

Great post and idea! I recently got into shell scripts as well trying to automate some stuff.

Not yet ready to share the full code because is quite trashy 👀 but this is a little snippet making, changing, and opening a directory in code for a fresh new project.

# MKDIR with the inputted name. If already exists, just ignore, continue anyways      
tput setaf 0; echo -n "Creating directory... "
mkdir $flpath 
tput setaf 2; echo "done."

# CD to the inputted folder
tput setaf 0; echo -n "Changing directory... "
cd $flpath 
tput setaf 2; echo "done."

# OPEN CODE from the folder
tput setaf 0; echo -n "Opening VS Code... "
code -n . 
tput setaf 2; echo "done."

Really loved finding out about tput setaf changing the color of the text in the terminal, it makes it look cooler.

Terminal new command

Also nice trick source ~/ in the zsh config file and it loads the new (or any other function) in the terminal as a command.

dmahely profile image
Doaa Mahely • Edited

This is really cool! That's gonna be a very useful script. I look forward to seeing the final result 😄

dlamblin profile image
Daniel Lamblin

This changed my life with bash:

CDPATH The search path for the cd command.  This is  a  
       colon-separated list  of  directories  in  which the
       shell looks for destination directories specified by
       the cd  command.   A  sample  value  is ".:~:/usr".

EG put all your projects in a project directory, add it to your CDPATH, and you can tab complete your project directory names with cd from any path any time.

mshjri profile image
Omar Al-Mashjari

Well, that is especially helpful while working from home.
8:59 AM - Home
9:00 AM - Work!!

jimpriest profile image
Jim Priest

I do something similar on may Mac using Alfred - I just enter 'work' and it pops open all my email, editor, browser and Slack/Teams, etc. Lazy for the win!

dmahely profile image
Doaa Mahely

That's awesome! I tried using Alfred some time ago but couldn't get used to it.

phase_seven profile image
Ratul Roy

Cool post! I usually put all my command in one python script, and run it after opening my workstation.

equiman profile image
Camilo Martinez

My favorite one 🤓

alias x="exit"
kewbish profile image
Emilie Ma

Did something similar to this - automation for the win! Saves a ton of time as well.

andrewbaisden profile image
Andrew Baisden

Reading this article makes me want to automate my whole workflow it would save me a ton of time that would be better spent doing other things.

herico profile image
Mamadou Korka Diallo

This is very neat and really productive. thanks

winnieire profile image
Irene Sarigu

Thanks for this information! 😊

dmahely profile image
Doaa Mahely

Thanks for reading Pavel 😄

armujahid profile image
Abdul Rauf

Nice! I also have similar startup script except I use browser's built in tab restore feature to restore my browser session with all tabs.

samborick profile image
Sam Borick

I do this too! I also start a toggl timer via their rest api. And I create standard 'getting started' checklist via the todoist.

ritwikshanker profile image
Ritwik Shanker

Great Article. A note for people who use Macbook's, you can use Automator tool which is inbuilt inside the system. Will really help you avoid 5-6 clicks in the morning.

dmahely profile image
Doaa Mahely

I'll have to take a look at the automator, thanks