Simplify Your Browsing: Open Firefox URLs with Aliases in Terminal
Tags: nerdy, terminal, productivity
Published: 2024-02-10 09:01:32

So there I was, sitting at the airport terminal, laptop out and Chrome up and running. A sudden need to open a URL in Firefox hit me, and I couldn't help but think, "Wouldn't it be cool to just whip up a Firefox window with that URL straight from my terminal?" That lightbulb moment turned into a mini-mission for me. Why toggle through screens and clicks when a simple terminal command could do the trick? 

This article is all about bringing that cool, 'aha' moment to life for you. If you're into making your tech life just a bit more slick and fun, you're definitely going to enjoy this productivity hack. Let's dive into how this little idea from an airport terminal can add a nifty twist to your digital routine!

Let's deconstruct the process in steps: 
- ⼻ Open up terminal
- ⼻ Check Firefox installation
- ⼻ Edit `.bashrc` or `.zshrc`
- ⼻ Playing around
- ⼻ Getting fancy with it

> Before we start with the crazy terminal hackaroo I suppose you have Firefox or Firefox developer edition installed.


## ⼻ Open up terminal

I made this a step because I wanted to shout out to this article [iterm2 your mac's terminal upgraded](https://sudorealm.com/blog/iterm2-your-mac-s-terminal-upgraded), and just let you know that you can easily upgrade your MacBook's built-in terminal very easily to a crazy efficient tool! That was the shout-out! Now just open your terminal 🤣 !


## ⼻ Check Firefox installation

After some minor searching around ways to do that directly from the terminal, I found that the best way is using the system_profiler command. 

```bash
system_profiler SPApplicationsDataType | grep Firefox

Location: /Users/d3ad_r1nger/Library/Application Support/Firefox/Profiles/xvmcok03.dev-edition-default/storage/default/https+++tinkerwell.app
    Firefox Developer Edition:
      Location: /Applications/Firefox Developer Edition.app
      Get Info String: Firefox Developer Edition 123.0
```

The output indicates that the "Firefox Developer Edition" is installed on my system, located in the /Applications directory, with version 123.0. Additionally, there's a reference to a Firefox profile or data directory located under the user's Library/Application Support/Firefox path, specifically within a development edition profile storage.


## ⼻ Edit `.bashrc` or `.zshrc`

Depending on what you use (I use zsh) edit the appropriate file. 

```bash
nano ~/.zshrc 
```

Add the following snippet to the end of your file. 
```bash
# functions
fire() {
    open -a "Firefox Developer Edition" "https://$1"
}
```
Save and exit the editor `ctrl + x` then press `y`. 

**📝 Sidenote**
You noticed that I use "Firefox Developer Edition" in the command. This is just the Firefox version I have installed. If you installed the simple Firefox version just add "Firefox". Just needed to clarify that to ease confusement!

Apply the changes by sourcing your profile or rc file:
```bash
source ~/.zshrc
```


## ⼻ Playing around
Now you can just type `fire sudorealm.com` and see your Firefox open up, navigating you to Sudorealm✨! Also if you type `fire pokemon.com/us/pokedex/mewtwo` you see that it just opens up a new tab to your already open Firefox window. How cool is that dude? 

![yeah bro!](https://i.giphy.com/ZxoslTYgYgWuk.webp)


## Getting fancy with it
I just can't stop at that point. There's this itch that I have to scratch, pushing the boundaries of what's possible with a simple terminal command. Why settle for just opening URLs when we can turn the dial up a notch? Here's how you can set this up to open multiple space-separated files or URLs in Firefox, all in one go. 🔥

```bash
# functions
fire() {
    for url in "$@"; do
        open -a "Firefox Developer Edition" "https://$url"
    done
}
```

Now we have unlocked a newfound power in our terminal! By just typing: 

```bash
fire instagram.com sudorealm.com youtube.com
```

Firefox will open everything all at once! I love it! Take a look! 👀

![the sudorealm way of opening links with firefox](https://i.postimg.cc/sXz8SWjH/Screen-Recording2024-02-10at10-02-05-AM-ezgif-com-video-to-gif-converter.gif)

You can do much more with that if you are curious enough, you can grab an idea from this article too: [From Frustration to Efficiency: My Experience with Aliases on Mac Terminal](https://sudorealm.com/blog/from-frustration-to-efficiency-my-experience-with-aliases-on-mac-terminal). In that article I play around with aliases. 

I might even create a new alias, now that I think about it, like `insta` that would immediately open Instagram for me. 🤪

**📝 Another sidenote**
This entire tutorial might also work with other browsers and there are many crazy combinations that you could try, but I am too lazy to think of any of them. so go at it! Maybe create an article about it here? 🤔

## Conclusions and Thoughts

And there you have it, folks—a journey from a simple 'aha' moment at an airport terminal to unlocking some pretty nifty tricks in your own terminal. Who knew a bit of waiting around with your laptop could lead to such a cool hack? By now, you've got the know-how to not only open URLs in Firefox with a simple command but also to juggle multiple sites like a digital juggler, all from the comfort of your command line.

This little adventure into the world of terminal commands and aliases shows that with a pinch of curiosity and a dash of creativity, the mundane can turn into something quite magical. It's more than just opening websites; it's about tailoring your tools to fit your workflow, making your digital life not just efficient, but also a bit more fun.

So, next time you're caught in a moment of downtime, maybe while waiting for a flight or just taking a break, remember that these are opportunities to explore, to tinker, and to perhaps stumble upon your next great hack. And who knows? Maybe your newfound command line prowess will inspire your next big idea or simply make your day-to-day a tad easier.

Don't forget to share your terminal triumphs and tips with the community. After all, sharing is caring, especially when it comes to cool hacks like these. Until then, happy hacking, and may your digital explorations bring you plenty of delightful surprises! 🚀


## 🚀 Spread the Love & Support the Realm

🆇 **X Shoutout**: Feeling extra grateful or have some cool feedback? Drop me a shoutout on Twitter – I'd love to hear from you! [d3adR1nger on X](https://twitter.com/DevThanos)

💬 **Join our Discord Server**: Join the **[Sudorealm Discord Server](https://discord.gg/Fy4bmw6q)** connect with fellow enthusiasts and chat about everything that fascinates you! From new blog post suggestions to seeking support on tricky tutorials. Come, share your ideas, and let's grow together! 🚀🌐

☕️ **Coffee Driven Development**: Love what you're reading? Fuel my passion for coding with a delicious cup of coffee! Every sip powers up another line of code and helps bring more exciting content your way. Support my caffeine-fueled coding adventures and let's brew up something amazing together! ☕👨‍💻 Join the journey and **[BuyMeACoffee](buymeacoffee.com/ZixcW8N)**

[![d3ad R1nger buymeacoffee](https://media.giphy.com/media/GNBCVMv6XobnMUMYJG/giphy.gif)](https://www.buymeacoffee.com/ZixcW8N)