DEV Community

loading...

Setting up your DEV machine in ONE script

Roland 🐺
Software Engineer, Dogs, he/him
Originally published at Medium on ・3 min read

A new computer is great 💻🎉 — It’s a clean slate. It’s snappy. It’s great… but it is missing all the tools I rely on every day! My work requires me to jump around in a variety of tools and technology stacks, hence I need to install a lot of different tools and be able to support different development environments.

Photo by Claude Piché on Unsplash

Existing package manager for CLI tools

Over time developers load command-line tools like people are buying toilet paper these days. From maven , via tl;dr , stopping at kubectl to tmux. We use all of those little nifty tools. Hence setting up a new machine can seem scary task at times, but fear not! For CLI tools we solved that problem long long ago with Homebrew, or as you probably know it: brew

(The windows folks probably know Chocolatey)

You can install maven for example by running: brew install maven

Fear not! The same tool that installs CLI tools can install (almost) all our applications!

Brew can do more!

Homebrew uses formulae (or recipes) to install the tools you need in it’s Cellar. However, it can tap into its casks if you need Slack, Atom, Visual Studio Code, Java, 1Password or SourceTree — enough with the puns! It’s literally as easy as installing a CLI package.

You probably heard about casks or seen it fly by in the console.. let’s look at an example. Let’s say you want to install Firefox using brew. All you need to type is:

brew cask install firefox

Brew will update its formulae, look for the application you want to install and do it right away.

> brew cask install firefox
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
abcmidi cataclysm contentful-cli llvm logtalk
==> Updated Casks
google-chrome           

==> Downloading https://download-installer.cdn.mozilla.net/pub/firefox/releases/
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'firefox'.
==> Installing Cask firefox
==> Moving App 'Firefox.app' to '/Applications/Firefox.app'.
🍺 firefox was successfully installed!
Enter fullscreen mode Exit fullscreen mode

Brew can’t install my application!

> brew cask install xcode                         
Updating Homebrew...
Error: Cask 'xcode' is unavailable: No Cask with this name exists. Did you mean “swiftformat-for-xcode”?
Enter fullscreen mode Exit fullscreen mode

Unfortunately not every app has a recipe on homebrew. However, you may just don’t know the correct name or have spelt it incorrectly. To double-check there is a useful brew search THE-THING-I'M-LOOKING-FOR and as long as it's not cat-pictures, you'll likely be successful.

In docker’s case, it will even give you formulae’s and casks:

> brew search docker                                                  
==> Formulae
docker docker-machine-driver-vmware
docker-clean docker-machine-driver-vultr
docker-completion docker-machine-driver-xhyve
docker-compose docker-machine-nfs
docker-compose-completion docker-machine-parallels
docker-credential-helper docker-slim
docker-credential-helper-ecr docker-squash
docker-gen docker-swarm
docker-ls docker2aci
docker-machine dockerize
docker-machine-completion lazydocker
docker-machine-driver-hyperkit
==> Casks
docker homebrew/cask-versions/docker-edge
Enter fullscreen mode Exit fullscreen mode

Ok, we get it, but where is that single script?

Ok… I’ve digressing about brew. To create a single setup script, it also needs to be able to install homebrew itself. Fortunately, that’s easy and available directly from brew’s website https://brew.sh

I combined everything I mentioned in a sample script, that I use myself:

An example script for brew using formulae and casks

This drastically reduced the amount of time to set up my environment (about 25 min, depending on internet connection) and will make it easier in the future, if I decide to rebuild the machine.

Potential improvements

Here are a few improvement ideas:

  • Identifying all the casks that require password and moving them at the beginning would simplify this script
  • Further improve the script to do all additional customization (desktop, os settings, …)
  • If you always work on the same projects, creating and executing a script with git clones and creating all the environments might be a good next step

I hope you find this article interesting and please let me know if you have any questions.

Resources

Originally published at Skofgar’s Blog.


Discussion (0)