Automate Your Terminal Makeover
Is setting up a terminal the first thing you do with a new computer? If yes, then this is for you.
Towards Data Science published my article, The Ultimate Guide to Your Terminal Makeover in April 2020. It is one of my most popular articles. It has more than 65 K views since it was published and about 300 views daily.
This month I had to install the terminal on my new laptop. Following the steps in my own article, I thought “Hmm, I can automate all these installations.”
Subsequently, I created Terminal Makeover Automated (Terma). It automates installing the following packages on a new Mac:
- Homebrew
- iTerm2
- ZSH
- Oh-My-Zsh
- Starship
- Snazzy iTerm theme
- Fira code fonts
- iTerm2 preferences plist
- Plugins: autojump, brew, git, zsh-syntax-highlighting, and zsh-autosuggestions.
Caution
I created Terma for a new Mac. If you already installed iTerm2 and plugins, I suggest saving the ~/.oh-my-zsh
directory, ~/.zshrc
file, and ~/Library/Preferences/com.googlecode.iterm2.plist
. I recommend using Automate Brew Installer first to save your brew list and then reinstall it after the Terma installation.
Installing Terma
Open a terminal and install the Awesome Package Manager.
Installing the Awesome Package Manager is easy. Run the following on your terminal:
curl -s https://raw.githubusercontent.com/shinokada/awesome/main/install | bash -s install
Once you have installed the Awesome Package Manager, install Terma.
awesome install shinokada/terma
Getting started
To run terma on your terminal, do the following:
terma
You’ll be asked for your password when installing Homebrew.
The Oh-My-Zsh installation exits the script, so you need to run terma
again.
terma
iTerm2 is ready to rock!
When you open the newly installed iTerm press Ctrl+right-click and select Open.
The iTerm Preferences Profile is set with the name “Terma”, Color Presets of Snazzy, and font Fira code.
You can use brew aliases, such as bubu
, auto-suggestions, auto jump, and all the above plugins.
Printing help
terma -h
Uninstalling Terma
You can remove all items installed including Homebrew. I suggest using Automated Brew Installation to save your brew list first.
terma uninstall
What I learned from writing Terma
At first, I wrote the script in Bash, then running source $HOME/.zshrc
requires a ZSH script. I converted the script to ZSH. All I needed to change was the read
command.
# Bash
read -rp "Do you want to uninstall? yes/y or no/n " PANS# ZSH
read "PANS?Do you want to uninstall Y/y or N/n? "
The script uses Homebrew to install packages except for Oh-My-Zsh. To avoid unnecessary error messages, the script sources appropriate .zshrc
files. For the iTerm2 configuration file, it copies a premade com.googlecode.iterm2.plist
file to the ~/Library/Preferences
directory.
The script uses a heredoc to show the final message. The Figlet program can create large letters.
Conclusion
Since you will be installing a number of programs with Terma, it takes some time to complete. I tested terma
on my 2015 Mac (x86_64) and 2021 Mac (ARM 64, M1 chip), and it worked flawlessly.
If you have your favorite iTerm2 setup, replace Terma’s com.googlecode.iterm2.plist
with your plist file in the ~/Library/Preferences/com.googlecode.iterm2.plist
directory.
Happy coding!
If you liked my article and would like to receive my newsletter, please sign up.