>_ improve your style and increase your productivity on the terminal with OH MY ZSH
John Johnson Okah
Posted on December 31, 2021
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.
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
Then made zsh the default shell ..with this command on the terminal:
chsh -s $(which zsh)
And after that, you will be prompted to enter your pc password.
password: *****
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
...and you will see this message.
Enter 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)"
you should see an output similar to this, while it installs:
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)
then add web-search to it, like this:
plugins = (git web-search)
save the .zshrc
file and return to the terminal.
Now enter exec zsh
on the terminal:
$ exec zsh
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
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"
and then change robbyrussel
to agnoster
, like this:
ZSH_THEME = "agnoster"
save the .zshrc
file and return to the terminal
Restart the shell or enter this command exec zsh
to reload terminal.
$ exec zsh
And Voila, you have a pretty looking terminal.
By default, the terminal will display something like this:
yourusername@yourmachinename ~/blah/blah/blah-directory
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
}
Save the file.
Then go to the terminal and enter exec zsh
to reload:
$ exec zsh
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:
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",
}
Save the file and restart vscode.
And we are all good 🥂
Don't forget to hit the like button. ❤️
Posted on December 31, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
December 31, 2021