Jerry Emilo

2020 Terminal Setup

✏️ Summary

Terminal configurations may not seem like the biggest deal, but for developers a systems terminal is an essential part of every day life. Over the years this is a part of a system that I’m constantly tweaking for my needs and tastes. My current setup is geared towards having a simple configuration that is lean and clean. This write up will go over the basics of setting up a terminal that will look good and have a lot of capabilities under the hood.

🧑‍💻 Developer Environment overview

Just FYI this was written specifically for Ubuntu 20.04. Although, this configuration should be pretty similar for most flavors of Linux and MacOS. Just make sure to review the instructions from the projects utilized during the process.

🧗‍♂️Guide

Shell - ZSH

I’ve never really had much of an opinion of ZSH vs BASH vs Whatever. However, recently MacOS changed it’s default shell to ZSH. Because I use both Linux and MacOS on a daily basis, I decided to just switch to ZSH for everything for consistency. ZSH itself pulls features from bash, ksh, tcsh, and has many of it’s own awesome features.

Update local packages

First let’s update our local packages to make sure our system and software repositories are all up to date.

sudo apt-get update
sudo apt upgrade

Install, Configure, and Enable ZSH

Now we will start setting up zsh by installing it and adding the zsh configuration to our home directory.

sudo apt install zsh
touch ~/.zshrc

Configure ~/.zshrc

After that ZSH is installed and ~/.zshrc has been created, we can configure it using the following baseline. For now this just enables enables some basic shell history.

# Set ZSH options
# Options details:
# http://zsh.sourceforge.net/Doc/Release/Options.html#index-HISTIGNOREALLDUPS
# http://zsh.sourceforge.net/Doc/Release/Options.html#index-SHAREHISTORY

setopt histignorealldups sharehistory

# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.zsh_history

Change shell to zsh

Now that we have zsh configured, let’s set it as our main shell.

chsh -s $(which zsh)

After we have changed ZSH to our main shell, an easy way to enable this system wide is just log in and out of our system.

We should have gone from

default

to

zsh

So far it’s actually not looking so great, but that will change as we keep going down this 🐇 hole.

Level up our font

Next let’s get setup with a new font that supports icons. Head over to https://www.nerdfonts.com. Go to their download section to grab the FiraCode Nerd Font. Once it’s on the box, here is a way to install it system wide.

# unzip the fonts into a directory
unzip FiraCode.zip -d FiraCode

# navigate into that directory
cd FiraCode

# move those fonts so they can be shared system wide
sudo mv * /usr/local/share/fonts

# update the font cache so your system loads up the new fonts
fc-cache -f -v

Style out your theme

A handy project that let’s you easily pick themes for your shell is http://mayccoll.github.io/Gogh/. Follow their install instructions, which will run a bash script that will do a guided install of the theme of your choice.

gogh splash

I generally keep all of my configurations all aligned, so I picked the VS Code Dark Plus theme.

gogh selection

After a theme is installed, http://mayccoll.github.io/Gogh/ will automatically set it as the default theme for the system. Next to our FiraCode which we previously installed, just configure the settings in the terminal preferences.

gogh config

Next we’re gonna blast into space

Now that we have a nice theme and fonts installed, we can setup a fancy shell prompt. For this we will be using https://starship.rs/. We can follow the instructions on their site, but we just need to modify them slightly from using bash to using zsh. First thing we need to do is install curl if it’s not already installed on the system, since it’s used in their install steps.

sudo apt install curl
curl -fsSL https://starship.rs/install.sh | zsh

After https://starship.rs/ installs, it will instruct us to add the following line to the end of the ~/.zshrc.

eval "$(starship init zsh)"

While we are in the ~/.zshrc, let’s add a simple alias to help us reload the zsh configuration easier.

alias rl='source ~/.zshrc'

The ~/.zshrc file should now look like this

# Set ZSH options
# Options details:
# http://zsh.sourceforge.net/Doc/Release/Options.html#index-HISTIGNOREALLDUPS
# http://zsh.sourceforge.net/Doc/Release/Options.html#index-SHAREHISTORY

setopt histignorealldups sharehistory

# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.zsh_history

alias rl='source ~/.zshrc'

eval "$(starship init zsh)"

Now for the first and last time, run the following command to reload our zsh configuration.

source ~/.zshrc

After this we can just run the rl command to reload our configuration. Now our shell should reload and look like this:

starship

Finally we are getting somewhere. The colors are nice, the font is easier to read, and we have some rad capabilities around customizing our shell prompt. Now let’s configure https://starship.rs/ a little to have some fun with it. They have a ton of options, but for now let’s just set some basic prompt icons.

Create this file ~/.config/starship.toml

touch ~/.config/starship.toml

Then add the following

[character]
symbol = "🚀"
error_symbol = "🤯"
use_symbol_for_status = true

Now let’s run rl to reload our shell again.

rl

It should look like this…

starship

Then if you navigate into say for instance this projects directory where git is being used…

starship

Get injected

Now that we have a fancy prompt, let’s add some plugin support. I’ve always been a big fan of https://ohmyz.sh. It has an extensive plugin library and huge community support. However, it’s kinda heavy and I came across this project http://getantibody.github.io/. It’s essentially a plugin manager that is much more lighter weight and supports loading ohmyzsh plugins. It’s super easy to setup.

Follow the instructions on their site by executing the following in your shell

curl -sfL git.io/antibody | sh -s - -b /usr/local/bin

Depending on your permission you may have to run sudo on the piped command

url -sfL git.io/antibody | sudo sh -s - -b /usr/local/bin

Then once it’s install, it has a few ways to setup plugins. The method we will use is creating a file called ~/.zsh_plugins.txt

For our purposes let’s just add the following

# The creaters plugin for creating dirs https://github.com/caarlos0/zsh-mkc
caarlos0/zsh-mkc
# zsh completions https://github.com/zsh-users/zsh-completions
zsh-users/zsh-completions

Notice they are just Github repositories? Pretty awesome huh. Which reminds me, we will also need to install git if it’s not already installed on the box.

sudo apt install git

Anyways, our ~/.zshrc should now look like this

# Set ZSH options
# Options details:
# http://zsh.sourceforge.net/Doc/Release/Options.html#index-HISTIGNOREALLDUPS
# http://zsh.sourceforge.net/Doc/Release/Options.html#index-SHAREHISTORY

setopt histignorealldups sharehistory

# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.zsh_history
# Load antibody
source <(antibody init)
antibody bundle < ~/.zsh_plugins.txt

# aliases
alias rl='source ~/.zshrc'

# blast into outer space
eval "$(starship init zsh)"

Now let’s run our rl alias, which will reload everything. We should be good to go with zsh, rad fonts, a delicious theme, a fancy shell prompt, and a lightweight powerful plugin manager. Enjoy

📨 Questions, Issues, and Suggestions?

For now this site doesn’t support any direct feedback. Please submit any questions, issues, or suggestions directly to me via Twitter.