Setup Mac OS Development Environment

Note: I am running macOS Mojave on a 2.8 GHz Intel Core i7 with 16 GB 2133 MHz LPDDR3 RAM. I am setting up my environment to write some awesome Clojure code.

This environment is for Clojure and NodeJS development using the Spacemacs configuration with Emacs and Vim bindings.

Homebrew

The missing package manager for macOS (or Linux).

Wiki | brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The script explains what it will do and then pauses before it does it. Read about other installation options. Install Homebrew on Linux and Windows Subsystem for Linux.

Java OpenJDK

OpenJDK is a free and open-source implementation of the Java SE Platform Edition.

Wiki | GitHub | StackExchange

brew tap AdoptOpenJDK/openjdk
brew install <version>

Versions:

  • adoptopenjdk-openjdk8
  • adoptopenjdk-openjdk9
  • adoptopenjdk-openjdk10

Clojure

Clojure is a modern, dynamic, and functional dialect of the Lisp programming language on the Java platform. Like other Lisps, Clojure treats code as data and has a Lisp macro system. The current development process is community-driven, overseen by Rich Hickey as its benevolent dictator for life.

Wiki | Clojure.org

brew install clojure

Leiningen

Leiningen is a build automation and dependency management tool for the simple configuration of software projects written in the Clojure programming language. Leiningen was created by Phil Hagelberg.

Wiki | GitHub | Homebrew

brew install leiningen

Node

Node.js is an open-source, cross-platform, JavaScript run-time environment that executes JavaScript code outside of a browser.

Wiki | NodeSource | NodeJS

sudo npm install npm --global # Update the `npm` CLI client

shell

iTerm2

iTerm2 is a GPL-licensed terminal emulator for macOS. It was derived from and has mostly supplanted the earlier "iTerm" application. iTerm2 supports operating system features such as window transparency, full-screen mode, Exposé Tabs, Growl notifications, and standard keyboard shortcuts.

Wiki | iTerm2

Zsh

The Z shell (zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.

Wiki | Zsh | Installation

Try zsh --version before installing it from Homebrew. If it's newer than 4.3.9 you might be OK. Preferably newer than or equal to 5.0.

brew install zsh zsh-completions

To set zsh as your default shell, execute the following for macOS High Sierra

chsh -s /bin/zsh

Assuming you have Homebrew installed. If not, most versions of macOS ship zsh by default, but it's normally an older version. Alternatively, you may also use MacPorts

sudo port install zsh zsh-completions

oh-my-zsh

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.

Ohmyz | GitHub

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Powerlevel9k

Powerlevel9k is a theme for ZSH which uses Powerline Fonts. It can be used with vanilla ZSH or ZSH frameworks such as Oh-My-Zsh, Prezto, Antigen, and many others. Get more out of your terminal. Be a badass.

GitHub

brew tap sambadevi/powerlevel9k
brew install powerlevel9k
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
ZSH_THEME="powerlevel9k/powerlevel9k" #update ~/.zshrc file

zsh-syntax-highlighting

This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.

GitHub

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

zsh-autosuggestion

It suggests commands as you type based on history and completions.

GitHub

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Activate plugins in ~/.zshrc under plugins:

plugins=(git
         zsh-syntax-highlighting
         zsh-autosuggestions)

Tools

Git

A distributed version-control system for tracking changes in source code.

Atlassian | Wiki | Installation

There are several ways to install Git on a Mac. The easiest is probably to install the Xcode Command Line Tools. On Mavericks (10.9) or above you can do this simply by trying to run git from the Terminal the very first time.

git --version

If you don’t have it installed already, it will prompt you to install it.

If you want a more up to date version, you can also install it via a binary installer. A macOS Git installer is maintained and available for download at the Git website.

You can also install it as part of the GitHub for macOS install. Their GUI Git tool has an option to install command line tools as well. You can download that tool from the GitHub for macOS website.

vim syntax highlighting

To enable the syntax coloring for vim, go to your home directory, and open or create the .vimrc file if it doesn’t already exist.

Codexpedia

cd ~
vim .vimrc
filetype plugin indent on
syntax on

Toggle syntax highlighting in Vim, press Esc and then type the below and enter:

:syntax <on|off>

Gatsby

Gatsby is a React-based, GraphQL powered, static site generator. It uses powerful preconfiguration to build a website that uses only static files for incredibly fast page loads, service workers, code splitting, server-side rendering, intelligent image loading, asset optimization, and data prefetching.

MediaCurrent | Gatsby

npm install -g gatsby-cli

Emacs

Emacs is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, self-documenting, real-time display editor".

Wiki | emacsformacosx

Spacemacs

It can take advantage of all of GNU Emacs' features, including both graphical and command-line user interfaces, and being executable under X Window System and within a Unix shell terminal.

Spacemacs consists mainly of configuration files, pre-defined internal commands, and configurations for various plug-ins (called 'packages').

It has three user-selectable input modes: Emacs mode, Vim mode (based on the evil Emacs package for Vim emulation), and Hybrid mode.

Wiki | Practicalli

In my case, Emacs could not verify the GPG signatures of packages downloaded from elpa. I applied the following workaround:

Modify the init.el in .emacs.d/initl.el, and add at or near the top of the file the following line; (setq package-check-signature nil)

Then the spacemacs configuration (edit ~/.spacemacs) needs to be modified to allow the editor to download packages from elpa via unsecure channels, this is done by modifying the following settings; dotspacemacs-elpa-https nil

Perhaps this will work to solve the issue instead of disabling the signature check and https. I haven't tried it yet.

brew install gnupg

When using helm, and helm-ag, the executable for silver surfer (ag) needs to be but onto your path so that emacs can find and use it.

brew install the_silver_searcher

GitHub

.spacemacs config

Keep a copy of your config under version control in the event something goes wrong when you change it.

Gist (configuration) | Practicalli

themes

Press SPC T n to cycle to the next theme in the list I now use apropospriate-dark configured under themes in the .spacemacs configuration file.

GitHub

Treemacs layer

This layer sets up a file navigation and project explorer side-window via Treemacs.

Layer | Keybindings

(setq-default dotspacemacs-configuration-layers '(
  (treemacs :variables
            treemacs-use-follow-mode t
            treemacs-use-filewatch-mode t
            treemacs-use-collapsed-directories 3
            treemacs-lock-width t)))

Adjusting window sizes

You may have a configuration where the golden ratio or zoom has been configured. Your windows won't be balanced (equal sizes when windows are split). Windows are expanded when they are focused while other windows appear smaller.

  • Toggle zoom SPC t g
  • Toggle golden ratio mode SPC SPC > golden-ratio-mode
  • Balance windows area SPC w =

Am I missing something?

Do you have something configured in your environment that is not in my setup? Feel free to share emoji-blush