Return to site

Oh My Zsh For Mac

broken image


Eldredge sewing machine serial numbers. Please follow me on Twitter for updates.

  1. Oh My Zsh Mac Brew
  2. Mac Zsh Oh My Zsh

May 09, 2019  Oh-My-Zsh is a framework for Zsh, the Z shell. Oh-my-Zsh configuration turned out to be not so straight-forward with instructions being scattered all over, so I decided to gather it all in one place. Today I will be sharing how to install Z Shell with oh-my-zsh and also customizing it with an Awesome Theme and Plugins to bring a pimp to your terminal. This is how the Final Setup will look like: 😎 This post is divided into 4 Parts. Setting Up Windows for ZSH installation (Cygwin & Cmder) Installing Oh-my-zsh. As default, Oh-My-ZSH comes with the theme default which is robbyrussell. But if you want to choose a different please go to the Themes page in GitHub. Choose the one you like the most and then use your favorite text editor ( nano, vim, emacs, sublimetext or even textedit ) to edit the file.zshrc located on your home folder.

I was a long-time Windows user, a fairly happy one, but as a developer, there were a lot of things that were missing for me and one of the main was the terminal experience. I'm not a fan of the closed ecosystem of Apple so Linux was an easy choice for me and I switched to Linux almost 3 years ago. I did start out with Ubuntu and later switched to Fedora which is my primary OS now. You can read about my setup here

  • @marz as temporary solution, you could active bash environment by typing source.bashrc and then go back to 'oh my zsh' environment by typing source zshrc command. After that conda will work perfect. Or you can fire single commnad source.bashrc && source.zshrc – chudasamachirag Aug 30 '19 at 5:50.
  • Once I moved to Mac, I changed my shell to use zsh using Oh My Zsh due to the rich experience it brings to the terminal. I was delighted to see all these themes and plugins, and then started looking for a theme that provided the same information posh-git prompt provided.

As a senior developer and open source community lead, I spent a lot of time on the terminal and a terminal with a nice developer experience instantly makes you happier and more productive. The default bash terminal is good for beginners but if you really want a powerful terminal you need something more than bash.

Let's see how to configure a powerful and productive terminal experience. The setup is based on what I have configured on my Fedora machine. The same setup can be recreated on any other Linux distribution, BSD or Mac as well. You just need to use the installation instruction from the tools for the given platform.

Below are the tools we would need for this.

Zsh

Zsh is one of the most feature-rich shells for Unix. It works on Linux, Mac, WSL, and BSD. There are alternatives like Fish which also offers similar features but I personally like Zsh.

  1. Check if Zsh is already installed by running zsh --version on your terminal. If not found, install it using your package manager.
    • Fedora: sudo dnf install zsh
    • Mac: brew install zsh zsh-completions
    • RHEL/CentOS: sudo yum update && sudo yum -y install zsh
    • Ubuntu/Debian: sudo apt install zsh
    • For other platform refer this
  2. Now make Zsh your default shell by running chsh -s $(which zsh).
  3. Log out and log in back again to use your new default shell.
  4. Test that it worked with echo $SHELL. Expected result: /bin/zsh or similar.
  5. Test with $SHELL --version. Expected result: zsh 5.6.2 or similar

Note: If you have installed Zsh for the first time and launch the shell it would prompt you to configure some settings. You can choose to ignore that by hitting q as we will configure it later on.

Oh-My-Zsh

Oh-My-Zsh gives the Zsh shell superpowers. Its a framework to manage Zsh configuration. It has plugins and themes for Zsh(A lot of them).

From their Github page:

Once installed, your terminal shell will become the talk of the town or your money back! With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, 'that is amazing! are you some sort of genius?'

Just install it. You need it :)

Terminal emulator/multiplexer

Optionally you can use a Terminal emulator that can manage windows and panes for you.

For Linux I would recommend using Tilix, I have been using it for 3 years and its just amazing.

For Mac, you can use iTerm2 which is very popular.

Alternatively, you can also use tmux if you want something lighter on your existing Terminal app on Linux, BSD or Mac.

Configuring Zsh

This is the fun part. Let us make the terminal awesome.

Install plugins

First, let us install some additional plugins that are not bundled with Oh-My-Zsh.

zsh-autosuggestions

Provides auto completion for shell commands.

Run git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions to install

zsh-syntax-highlighting

Provides syntax highlighting on the shell.

Run git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting to install

autojump

Provides a smarter directory navigation system. Install autojump for your OS following instructions here.

Now let us configure the ~/.zshrc file with some settings. Here is my full .zshrc file. Your mileage may vary.

Add exports

We will start with some exports.

Zsh settings

Now we can configure some Zsh specific settings

Zsh

Zsh theme

Now, Let's set up a nice theme. I'm using powerlevel10k as my current theme and it's fast and looks great. You can use the default or you can choose any theme you like from the list here. If you like my theme then follow these instructions. Thanks to Roman Perepelitsa for some cool tips

Run git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k to install the theme.

Install a Powerline font. I use Adobe Source Code Pro

Add the below configuration to the ~/.zshrc file.

Enable plugins

We can finish off by enabling the plugins and some tweaks

And that's it we are ready. Start a new terminal session and enjoy.

Issues & workarounds

If you use Tilix as your terminal emulator, then this might be required for proper pane splitting. Add this to your ~/.zshrc

If you are getting errors from the zsh-completion plugin, you might want to add this to the beginning of your ~/.zshrc

If you encounter an error from Oh-My-Zsh saying [oh-my-zsh] Insecure completion-dependent directories detected, set ZSH_DISABLE_COMPFIX=true right before the line source $ZSH/oh-my-zsh.sh in your ~/.zshrc file and restart your session or run exec zsh

Dockerized playground.

If you have Docker installed then you can use the below snippet to try this setup in a sandbox without installing anything or affecting your existing setup.

VSCode Tip

If you are using VSCode like me, you might want to do the below to get the same terminal experience in the integrated VSCode terminal as well.

Follow these steps

  • Download and install a patched font.
  • On Linux, run fc-cache -f -v to refresh font cache.
  • On VSCode, open Preferences → Settings and click on the {} icon to open JSON mode and set the below

    Replace linux with osx if you are on a Mac.

I hope you like it. If you have any questions or if you think I missed something please add a comment.

If you like this article, please leave a like or a comment.

You can follow me on Twitter and LinkedIn.

Also published at Dev.to

If you are a developer, coder, sysadmin or IT Pro I assume that you have used the terminal either on your Unix, Linux, Mac o Windows. And the shell that usually comes as default is the good old faithful BASH shell, which is nice but not cool.

Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a other cool things.

Oh My Zsh For Mac

Zsh theme

Now, Let's set up a nice theme. I'm using powerlevel10k as my current theme and it's fast and looks great. You can use the default or you can choose any theme you like from the list here. If you like my theme then follow these instructions. Thanks to Roman Perepelitsa for some cool tips

Run git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k to install the theme.

Install a Powerline font. I use Adobe Source Code Pro

Add the below configuration to the ~/.zshrc file.

Enable plugins

We can finish off by enabling the plugins and some tweaks

And that's it we are ready. Start a new terminal session and enjoy.

Issues & workarounds

If you use Tilix as your terminal emulator, then this might be required for proper pane splitting. Add this to your ~/.zshrc

If you are getting errors from the zsh-completion plugin, you might want to add this to the beginning of your ~/.zshrc

If you encounter an error from Oh-My-Zsh saying [oh-my-zsh] Insecure completion-dependent directories detected, set ZSH_DISABLE_COMPFIX=true right before the line source $ZSH/oh-my-zsh.sh in your ~/.zshrc file and restart your session or run exec zsh

Dockerized playground.

If you have Docker installed then you can use the below snippet to try this setup in a sandbox without installing anything or affecting your existing setup.

VSCode Tip

If you are using VSCode like me, you might want to do the below to get the same terminal experience in the integrated VSCode terminal as well.

Follow these steps

  • Download and install a patched font.
  • On Linux, run fc-cache -f -v to refresh font cache.
  • On VSCode, open Preferences → Settings and click on the {} icon to open JSON mode and set the below

    Replace linux with osx if you are on a Mac.

I hope you like it. If you have any questions or if you think I missed something please add a comment.

If you like this article, please leave a like or a comment.

You can follow me on Twitter and LinkedIn.

Also published at Dev.to

If you are a developer, coder, sysadmin or IT Pro I assume that you have used the terminal either on your Unix, Linux, Mac o Windows. And the shell that usually comes as default is the good old faithful BASH shell, which is nice but not cool.

Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a other cool things.

Below are some facts about it:

  • More than 200 plugins. Enhance your productivity with plugins that integrate into git, google, youtube, sublime and much more.
  • More than 1000 contributors. Since its Open Source, the code is available for free on GitHub and you can add your modifications, plugins and themes. Just submit your pull request!
  • More than 140. Don't be a dull bird using the old BASH simple theme. Add colors and other functionalities by using any of the themes.

Check this screen captures:

Oh My Zsh Mac Brew

And these are just some of the ways your terminal or console can look like. Pretty awesome right?

Dude, its a piece of cake. Just go to your Terminal or iTerm2

And type:

This will do the entire process of installing all the required pieces to make it work. Once it finishes you can go ahead and customize the themes & plugins.

As default, Oh-My-ZSH comes with the theme default which is robbyrussell. But if you want to choose a different please go to the Themes page in GitHub. Choose the one you like the most and then use your favorite text editor (nano, vim, emacs, sublimetext or even textedit) to edit the file .zshrc located on your home folder. Below are the commands to open such file on nano & vim:

Then you will have to locate the string:

Mac Zsh Oh My Zsh

And change it to the theme that you selected, on this case I chose the theme called Blinks, so I went ahead and edited the .zshrc file and put this string instead of the one above:

Then save the file and exit the editor. Please note that you will NOT see an immediate change on your current session. You would have to start a new terminal session to see the new theme applied there.

Now if you are a free soul like me, then you might want to set the value to random, that way each time you open the terminal you will experience a new theme until you find the one that you love the most. To enable this awesomeness simply use this string instead of the two previous ones:

Cool? Dude you know it is cool!

Just like Themes, enabling and disabling plugins is done thru a text editor and your file .zshrc. You will need to look for the string:

Where xxxx can be anything.

Since you are on Mac, I suggest all these plugins to be enabled:

But there are several more, just go to the Plugins page on GitHub to learn about them all.

Please note that the same rule of the themes applies here, you will need to save the file and open a new session to see the plugins enabled.

So that is all folks. Start experimenting with Oh-My-ZSH and help the creator of this awesome shell by buying some swag for you and your friends!

Comment below if I missed anything! Thanks!





broken image