Bootstrap your terminal environment in MacOS with a single Bash script

How often do you face the issue with configuring your development environment? How often do you configure your terminal? Did you install Command Line Tools? What about Homebrew, don’t you forget to install it? Maybe you forgot about some cool plugin for your shell and can’t find it?

This is the problem I am usually faced with clean MacOS install, so maybe you too.

Some error in the terminal, oh, I forgot to install X…
How did that work before? Oh, I had plugin Y, but I don’t remember its name…
Who enjoys remembering all the fishy commands? I don’t…
Burn out my own eyes with a default theme and colors? No, thanks…
Navigating through a plugin repository of your shell to find out all plugins you had
again? Haha, nope…

In case you just want to check the script, here is the link – https://github.com/ghaiklor/iterm-fish-fisher-osx

Further content is the history, my motives, while creating the script.

Solution

It might sound silly, but write all the steps, dependencies, plugins, etc. you install somewhere in notes or gist.

It was my solution before. I had a gist where I wrote all the steps I needed to do for setting up my glance terminal. You can look into it here.

And you know what? It has a huge amount of steps I need to do every time manually, while setting up my terminal environment: install Git, Homebrew, download iTerm, install color scheme and nerd font, download and configure shell and so on, and so on…

It’s boring, we need to fix that!

Automation is good, so long as you know exactly where to automate.

Eliyahu Goldratt

Solution v2

What if, we do the same as before, but write the steps in Bash script instead?

That’s how I came up with an idea of creating a common Bash script that will do all the steps I do manually, but on its own.

GitHub repository was born, Gist updated regarding newly created repo, initial commit with Bash script was created -> repository link.

Testing

Turns out, it worked perfect. Everything from my setup installed correctly.

I got my development environment just by executing Bash script with a single command in terminal (while drinking my coffee at the kitchen).

But I didn’t like hard-coded steps, even when I have some of required dependencies, for instance, Command Line Tools.

Why do I need to install something that I already have?

Solution v3

I improved the bash script with control flow instructions.

From now on, script could understand what you have installed and what not.

Do you have Command Line Tools installed? Ok, skip…
Do you have iTerm installed already? Ok, skip…
Do you want to have my color scheme or font? No, skip…

I did modifications, script was published and tested out on my friends — works with no issues. Finita!

Do I need this script?

Well, you may ask this question to yourself and I will give you the answer.

Do you work with terminal a lot, but too lazy to set it up? — Yes.
Is my setup fine for you and you like it? — Yes.
Do you have your own configuration? — Possibly, no.

What exactly am I setting up?

  • Command Line Tools (xcode-select — install)
  • Homebrew (ruby -e {HOMEBREW_INSTALLER})
  • iTerm2 (brew cask install iterm2)
  • Material design theme for iTerm2 and patched nerd fonts
  • Fish Shell (brew install fish)
  • Fisherman (curl -o ~/.config/fish/functions/fisher.fish {FISHERMAN})
  • 18 plugins for Fish (curl {MY_INSTALLER.sh} && ./MY_INSTALLER.sh)

Thanks

Thanks for reading. Please share it with your friends who are frustrated with setting up the environment.

Do you have any suggestions and ideas for further improvements? Please, ping me on Twitter or raise an issue in repo.


Eugene Obrezkov, Senior Software Engineer at @elastic.io, Kyiv, Ukraine.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.