DEV Community

Cover image for >_ improve your style and increase your productivity on the terminal with OH MY ZSH
John Johnson
John Johnson

Posted on • Updated on

>_ improve your style and increase your productivity on the terminal with OH MY ZSH

When I heard Mac OS has made zsh the default shell, then I began to wonder πŸ€” ...there must be something someone isn't telling me.
find out one day And amma find out today!


Zsh Setup

The first problem I encountered was deciding what to call it
(zssssh or z-shell🀷). After thinking a bit, I was like "fuck it!, let's get down to business".

The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.

Installing zsh (Z shell)

I installed zsh with this command:

$ sudo apt-get zsh
Enter fullscreen mode Exit fullscreen mode

Then made zsh the default shell ..with this command on the terminal:

chsh -s $(which zsh)
Enter fullscreen mode Exit fullscreen mode

And after that, you will be prompted to enter your pc password.

password: *****
Enter fullscreen mode Exit fullscreen mode

Now we have zsh installed and it has been made the default shell

You may need to restart your computer for this to take effect.


zsh configuration

Enter zsh on the terminal and hit enter ↡:

$ zsh
Enter fullscreen mode Exit fullscreen mode

...and you will see this message.
zsh promptEnter 2 to get the default configuration

Now the zsh is up and running. Over to "Oh My Zsh".


Oh My Zsh setup

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration. Sounds boring. Let's try again. Oh My Zsh will not make you a 10x developer...but you may feel like one.

Install oh-my-zsh via curl

$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Enter fullscreen mode Exit fullscreen mode

you should see an output similar to this, while it installs:

oh-my-zsh installation
Oh My Zsh is now installed, and we will use the .zshrc file for customizing the terminal


Customizing Oh My Zsh

With the .zshrc file you can add plugins and change the theme of your terminal.
The .zshrc file is located at the home directory ~/.zshrc

Oh My Zsh Plugins

Open the .zshrc file and find this line:

plugins = (git)
Enter fullscreen mode Exit fullscreen mode

then add web-search to it, like this:

plugins = (git web-search)
Enter fullscreen mode Exit fullscreen mode

save the .zshrc file and return to the terminal.

Now enter exec zsh on the terminal:

$ exec zsh
Enter fullscreen mode Exit fullscreen mode

to reload the terminal.

the exec zsh for reloading the terminal is one of the "zsh goodies".

With the web-search plugin you added, you can now google for stuff from the terminal.
Like this:

$ google what is zsh
Enter fullscreen mode Exit fullscreen mode

and your browser will pop-up and search for "what is zsh"


Oh My Zsh Theme

Open the .zshrc file and find this line:

ZSH_THEME = "robbyrussell"
Enter fullscreen mode Exit fullscreen mode

and then change robbyrussel to agnoster, like this:

ZSH_THEME = "agnoster"
Enter fullscreen mode Exit fullscreen mode

save the .zshrc file and return to the terminal
Restart the shell or enter this command exec zsh to reload terminal.

$ exec zsh
Enter fullscreen mode Exit fullscreen mode

And Voila, you have a pretty looking terminal.

productivity tom + style girlfriend


By default, the terminal will display something like this:

yourusername@yourmachinename ~/blah/blah/blah-directory
Enter fullscreen mode Exit fullscreen mode

Here is how you get rid of the yourmachinename part:

  • add this code at the end of the .zshrc file
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
  fi
}
Enter fullscreen mode Exit fullscreen mode

Save the file.

Then go to the terminal and enter exec zsh to reload:

$ exec zsh
Enter fullscreen mode Exit fullscreen mode

terminal screenshot

That was how Zsh became my default shell and bash was ...bashed πŸ’₯.


Extra Tip: how to fix display error on vscode in-built terminal

If you open up your vscode terminal and it looks like this:

vscode terminal display error

Don't be scared, there is nothing to worry about, it's just some font issue.

  • Go to the vscode User settings.json file (for Ubutu users: the settings.json file lives here: /home/$USER/.config/Code/User/
  • Add this command "terminal.integrated.fontFamily": "Ubuntu Mono, Monaco, PowerlineSymbols" to the file
{
// ...other vscode settings,

"terminal.integrated.fontFamily": "Ubuntu Mono, Monaco, PowerlineSymbols",
}
Enter fullscreen mode Exit fullscreen mode

Save the file and restart vscode.

vscode ternimal error display solved

And we are all good πŸ₯‚

Don't forget to hit the like button. ❀️

Discussion (3)

Collapse
sso profile image
Sall

Or just visit: z-shell.pages.dev/ :)

Collapse
jjokah profile image
John Johnson Author

zi :)

Collapse
sso profile image
Sall

If you need help to get up and running i can help with that :) Or if you like cool tech, open-source and zsh - we have many projetcs to join at ;)