DEV Community

Cover image for How to install custom plugins and themes with Oh-my-ZSH
Lars
Lars

Posted on • Originally published at blog.larsbehrenberg.com

How to install custom plugins and themes with Oh-my-ZSH

*This post was first published on my blog and is the 2nd part of my series about iTerm2 and Oh-My-ZSH.

In the first part of the series, we talked about how to install and set up your terminal to get you up and running quickly and with little effort, but with functionality and style.

Now we want to dive a little deeper, go past the default plugins, and explain a little more about Oh-My-ZSH and how it works.

Table Of Contents

Where to find your plugins and themes

Now that we have set up our iTerm2 with Oh-My-ZSH, let's try to understand what it is we installed and we are the files to configure it.

Plugins

When we setup up our default plugins in the first part of this series, we simply added them to the array of plugins listed in the ~/.zshrc, like so:

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
    git
    brew
    heroku
    gatsby
    yarn
)
Enter fullscreen mode Exit fullscreen mode

but how did they get installed from there?

What you might not know is that, during our installation of Oh-My-ZSH, all of the plugins that are listed in the official documentation were installed at ~/.oh-my-zsh/plugins. So, that once you add a plugin in the array and restart iTerm2, all that Oh-My-ZSH needs to do is to fetch that already installed plugin from the plugin folder and give you a seeming less experience.

If you want to have a look yourself what plugins you currently have installed simply execute this, to see all the plugins your terminal:

ls ~/.oh-my-zsh/plugins
Enter fullscreen mode Exit fullscreen mode

Or this to view in your Finder:

open ~/.oh-my-zsh/plugins
Enter fullscreen mode Exit fullscreen mode

Themes

The same counts for your themes! On installation of Oh-My-ZSH, lots of different themes were installed for you to be accessed at any time. Just swap out plugins for themes in your terminal command and you will see all the current themes installed.

To see installed themes in your terminal:

ls ~/.oh-my-zsh/themes
Enter fullscreen mode Exit fullscreen mode

Or to see them in your finder, write:

open ~/.oh-my-zsh/themes
Enter fullscreen mode Exit fullscreen mode

From here, you can go off on your own and look around in your ~/.oh-my-zsh, try to understand the different subfolders and config files.

However, in this tutorial, we will stick to themes, plugins, and the ~/.zshrc config file to config everything.

So let's get going!

How to install custom plugins & themes

We now know that Oh-My-ZSH looks for plugins and themes in the respective directory under ~/.oh-my-zsh.

So... Does that mean we simply have to create a folder with a custom plugin/theme in that directory and Oh-My-ZSH will be able to source it on start?

That's exactly it.

You add a folder with the custom plugin in your plugin directory and you are good to go.

Some people however prefer to put their custom plugins, themes, and configuration in a "custom" folder within the ~/.oh-my-zsh directory. By default this folder is called: ~/.oh-my-zsh/custom and then for example for plugins go into: ~/.oh-my-zsh/custom/plugins

Oh-My-ZSH will by default be able to source your plugins from there as well, but it's really up to you. You can add your custom plugins to the general plugin directory or your custom plugin directory. It's only personal preference.

One quick note here: Be wary, your terminal might slow down, the more plugins you add to your config. Add your plugins wisely!

Now let's add a custom plugin.

Oh-My-ZSH provides us with a small list of custom plugins to choose from in their official repo:

Oh-My-ZSH Custom Plugin list

And in this tutorial, we will go with the most enjoyable one of that list:

"Dogesay" Custom ZSH plugin

This plugin lets doge repeat your command every time you write in your terminal. Wait for it, it's going to be awesome.

To install the plugin we will have to download the plugin and move it into the correct directory. In this case, since it's a plugin: ~/.oh-my-zsh/plugins

Let's do this in one command:

git clone https://github.com/txstc55/dogesay ~/.oh-my-zsh/plugins/dogesay
Enter fullscreen mode Exit fullscreen mode

This clones the plugin from GitHub right into your new dogesay folder within ~/.oh-my-zsh/plugins.

So that now, all that is left to do is to add the plugin to our array of plugins in our ~/.zshrc.

For text editor users:

open ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Or VIM users:

vim ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

And add the plugin to this list:

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
    git
    brew
    heroku
    gatsby
    yarn
    dogesay
)
Enter fullscreen mode Exit fullscreen mode

Restart your terminal and done! Every time you enter a command in your terminal doge will make sure you know what you just entered! And with this, you have set up your first CUSTOM plugin. The same process works for all other custom plugins and themes. But if you do have any questions make sure to reach out to me on Twitter πŸ™‚

Alt Text

To get the coloring and bigger font for the callout, you will have to install "figlet" and "lolcat" with:

brew install figlet lolcat
Enter fullscreen mode Exit fullscreen mode

There are lots of custom plugins and themes out there with a big community developing and maintaining them. It's well worth checking some of them out. Who knows, maybe you might even want to submit a pull request to one of them!

One plugin that I use is:

Oh-My-ZSH Reminder

This plugin lets you create little to-do lists right within your terminal, so you can jot down little things that you need to get done until the end of your day. Hope you like it!

That’s pretty much it!

Thanks so much for reading this far and feel free to reach out to me anytime, on my website or Twitter πŸ™‚ And if you like to read more, make sure to check out my other posts on my blog!

Top comments (0)