My five step guide to Terminal Bliss

Oct 06, 2018 — 3 mins read

For a developer, a good terminal setup can make your life a lot easier and with the proper tools and plugins, you can save a lot of time as well. When setting up a new Macbook (or MacOS installation), I stick to my five steps in setting up the perfect terminal configuration.

1. iTerm2

Although MacOS comes with a pretty capable terminal app, iTerm is better in every way. Its highly configurable, its appearance can be set to your liking (it has some nice transparancy / blurring effects), it comes with loads of keyboard shortcuts, and much more.

You can download it for free, but I suggest you leave a donation for the great effort.

2. Brew

Give your Mac "apt-like" powers by installing Brew, a great packaging manager. Installing Wget, Nginx or PHP suddenly becomes a breeze. Here are some Brew packages I install right of the bat:

  • Wget
  • VIM
  • Git
  • PHP
  • Composer

Brew is even capable of installing entire Mac apps, like Firefox, etc.

Download Brew right away.

3. Nerd Fonts

A nice looking font can make your source code so much more readable - without changing a single line. Furthermore, it can provide you with additional characters you can use in your terminal (see Oh My ZSH below).

In iTerm, I use the DejaVu Sans Mono patched font. Besides being acknowledged as a font for technical work, it clearly distinguishes a few characters that are easily confused (like the lowercase 'l' and number one '1').

In my IDE's, I use Fira Code with ligatures. It presents popular programming symbols like an arrow (=>) or strictly equal (===) in a really nice way.

Download them on nerdfonts.com or using Brew.

4. Oh My ZSH

Bash comes as a default with MacOS, but like iTerm2, oh-my-zsh can take your shell experience to another level. Sophisticated auto-completion, theming, and plugin support are just a few examples that could make you jump ship.

Since I like a minimal shell prompt, I created my own theme called Mnml. It shows only the information that is relevant (like "only show git info when in a Git folder", "only show hostname when SSH'ing on a remote machine", "only turn red when using root account").

There are some built-in plugins you might want to enable right away in your .zshrc file. This is what my list looks like

plugins=(git composer npm vagrant laravel5)

A special recommendation for zsh-autosuggestions, which enhanced auto-completion with a kind of "preview", allowing you to type less and use your command history to your advantage.

Download oh-my-zsh - again - for free, but you can support them by buying a T-Shirt in their store (like I did).

You can download my theme using wget:

wget -q -O .oh-my-zsh/themes/mnml.zsh-theme https://raw.githubusercontent.com/thijskok/zsh-theme/master/mnml.zsh-theme

Activate it by editing your .zshrc file and changing the ZSH_THEME variable to "mnml".

5. Git

Last, but no least, download the latest Git. Before Git, version control was a mess. Git comes as standard with MacOS, but you can use Brew to get a more recent version:

brew install git

After that, its just a matter of configuring it to your liking. I use a couple of aliases as shortcuts. You can set them up in your shell:

git config --global alias.l 'log --oneline --decorate --all --graph' 
git config --global alias.s 'status -s' 
git config --global alias.cm 'checkout master' 

git config --global alias.save  '!git add -A && git commit -m "!squash"'
git config --global alias.restore 'reset HEAD~1'
git config --global alias.squash 'rebase --interactive --autosquash'
git config --global alias.feature  '!git  add -A && git commit -m "!squash"'

git config --global alias.upstream 'remote add upstream'
git config --global alias.updatefork '!git fetch upstream && git rebase upstream/master'
git config --global alias.undocommit 'reset HEAD~1 --mixed'

And... that's it!

Well, almost. There are a few tweaks left, that I will post in the near future, like command aliases, using VIM, etc. I hope this is useful in some way to anyone out there!

Read this next

Clipboard managers save lives

Clipboard managers to the rescue! They are simple tools that store every bit of copied information in a series of predefined slots, thus pre...