How I customise my Terminal with Oh My Zsh (macOS)

As a software engineer I use the command line every day. It’s very important to me that the tool I stare at for hours looks nice and that I have a set up that saves me time and energy. I use the macOS default Terminal because that’s what I used when I …


This content originally appeared on DEV Community and was authored by Hannah Gooding

As a software engineer I use the command line every day. It's very important to me that the tool I stare at for hours looks nice and that I have a set up that saves me time and energy. I use the macOS default Terminal because that's what I used when I started learning to code and I'm loath to change (soz). The macOS Terminal is a ZSH terminal shell (aka Z shell) which runs on a Unix-like operating system (macOS, Linux, BSD, Windows/WSL2). This post will go through how I set mine up on my personal MacBook Air (2015) running Big Sur, your experience on a different operating system may differ but luckily Oh My Zsh is a very popular framework so there will probably be people on Stack Overflow/Reddit who have encountered the same issues!

Step 1: Downloading Oh My Zsh

Oh My Zsh is opensource framework for terminal configuration that has loads of themes and plugins.

You can download Oh My Zsh from their website via curl or wget by copying and pasting the command. Make sure you're in your system's root folder.

Step 2: Configuring the .zshrc file

The .zshrc file contains the script that is run when you start a new zsh shell (rc stands for "run commands"). So if you make changes to this file you have to start a new shell to see them take effect.

You can customise your terminal by running open ~/.zshrc to open the .zshrc file in your system's root folder (the ~ tilde symbol means home directory).

Note: if you're on macOS Catalina or above you may get the error zsh: permission denied: - you will need to configure permissions to open the file with chmod +x ~/.zshrc.

Step 3: Changing the Terminal theme

Choose your theme from the Oh My Zsh Themes and change the ZSH_THEME="" line in the .zshrc file.

I use the agnoster theme so I have ZSH_THEME="agnoster" in my .zshrc file.

When you run a new shell you should see it has a new theme - yay! But wait...what are all those questions marks? You need to download the fonts to see the cool symbols!

Step 4: Installing Powerline Fonts

Follow the instructions on the Powerline fonts README to download the fonts needed for your new theme.

Step 5: Changing your Terminal Fonts

Go to Preferences > Profiles > Font to change the font for your Terminal to any of the fonts that have Powerline in the name. I use Meslo LG L DZ Regular for Powerline. You can either change the Basic profile or make a new profile and make that your default profile.

Now the question marks should be replaced with cool symbols. The purple arrow indicates what directory you are in, and the green arrow indicates what branch you are on if you are in a git initiliased directory.

Step 6: Changing your colours

You can play around with the colours in the Terminal Profiles yourself but I would suggest going with a pre-made theme because they will have considered the constrast and readability of the colours in different scenarios. Here's a list of cool MacOS Terminal Themes.

I use the VS Code Dark Plus theme which looks like this:

You can download the .terminal file and go to your Terminal Preferences > Profiles and import it as a new profile. Then select Default to make it your default theme.

Now it looks beautiful! ? ?

Plugins

There's so many other things you can do with Oh My Zsh. Have a look at the plugins it comes bundled with. I use the aliases that come with the Git plugin every day. An alias is a shortcut for a command that you write instead of the command and it runs the command.

The Git aliases I use the most are:

Alias Git Command
ggp git push origin $(current_branch)
gcb git checkout -b
gco git checkout

Aliases

You can add your own custom aliases by adding them to your .zshrc file

The bottom of the file has the syntax for aliases in comments:

# Example aliases
# alias zshconfig="mate ~/.zshrc"

I have the command for editing my .zshrc file under the alias edit. I prefer editing the file in VS Code* so I have this in my file:
alias edit="code ~/.zshrc"

*The instructions to set up launching files in VS Code from the command line can be found here for macOS.

? That's all! ?

Customising the Terminal is a great place to start personalising your tooling, apparently you can do even cooler things with iTerm2 and you can customise that in much the same way as I've outlined in this tutorial.


This content originally appeared on DEV Community and was authored by Hannah Gooding


Print Share Comment Cite Upload Translate Updates
APA

Hannah Gooding | Sciencx (2021-04-30T13:53:33+00:00) How I customise my Terminal with Oh My Zsh (macOS). Retrieved from https://www.scien.cx/2021/04/30/how-i-customise-my-terminal-with-oh-my-zsh-macos/

MLA
" » How I customise my Terminal with Oh My Zsh (macOS)." Hannah Gooding | Sciencx - Friday April 30, 2021, https://www.scien.cx/2021/04/30/how-i-customise-my-terminal-with-oh-my-zsh-macos/
HARVARD
Hannah Gooding | Sciencx Friday April 30, 2021 » How I customise my Terminal with Oh My Zsh (macOS)., viewed ,<https://www.scien.cx/2021/04/30/how-i-customise-my-terminal-with-oh-my-zsh-macos/>
VANCOUVER
Hannah Gooding | Sciencx - » How I customise my Terminal with Oh My Zsh (macOS). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/30/how-i-customise-my-terminal-with-oh-my-zsh-macos/
CHICAGO
" » How I customise my Terminal with Oh My Zsh (macOS)." Hannah Gooding | Sciencx - Accessed . https://www.scien.cx/2021/04/30/how-i-customise-my-terminal-with-oh-my-zsh-macos/
IEEE
" » How I customise my Terminal with Oh My Zsh (macOS)." Hannah Gooding | Sciencx [Online]. Available: https://www.scien.cx/2021/04/30/how-i-customise-my-terminal-with-oh-my-zsh-macos/. [Accessed: ]
rf:citation
» How I customise my Terminal with Oh My Zsh (macOS) | Hannah Gooding | Sciencx | https://www.scien.cx/2021/04/30/how-i-customise-my-terminal-with-oh-my-zsh-macos/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.