Subscribe

I've automated my morning routine πŸ€–

✍️

Bash script to open browser tabs

31 Aug, 2020 Β· 1 min read

Call me lazy, but I love automating things. Today we are automating my morning routine.

You may be wondering what that routine is.

  • Make coffee (Shit, we won’t automate this, Yet!)
  • Open ten tabs

Yes, that last part we are automating using the magic and mighty bash!

See here how cool this project is:

Bash opening browser tabs

Note: This script is written/tested on Mac and can differ for you on different machines.

First, we will be making a plain old .txt file that will hold all the pages we want to open:

https://hashnode.com/
https://daily-dev-tips.com/
https://twitter.com/

Now we will be making a bash script to open all browser tabs:

alias google-chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
while reading line; do
    google-chrome --new-tab "$line"
done < ~/www/browser-hack/list.txt

I have defined the alias for google-chrome; I think you can leave the alias out (untested) on windows.

Then we will loop through each line defined in list.txt and call google chrome to open a new tab for that website.

Next, we can add an alias to make it even cooler:

alias morning=~/path/to/script/bash.sh

Now in your terminal, type: morning and see the magic happen.

Voila, we just hacked our morning routine to be that much quicker!

You can find this project on Github: Browser-hack

Thank you for reading, and let’s connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Spread the knowledge with fellow developers on Twitter
Tweet this tip
Powered by Webmentions - Learn more

Read next πŸ“–

Counting all words across markdown files ~ CLI

13 Jun, 2022 Β· 1 min read

Counting all words across markdown files ~ CLI

Bash CleanMyMac alternative 🧼

11 Sep, 2020 Β· 1 min read

Bash CleanMyMac alternative 🧼

Join 2098 devs and subscribe to my newsletter