Share on Social Media

In this article, you will learn about the Oh My Zsh! A Fancy Linux shell for developers. #centlinux #linux #zsh

What is Zsh?

Zsh, short for Z Shell, is an extended version of the Bourne Shell (sh), which is a command-line interpreter for Unix-based operating systems. Zsh offers many enhancements over traditional shells like Bash, including advanced scripting capabilities, improved tab completion, and extensive customization options.

Some key features of Zsh include:

  1. Advanced Tab Completion: Zsh provides powerful tab completion features that can complete commands, file paths, variables, and more. It can even suggest completions based on context and history.
  2. Customization: Zsh is highly customizable, allowing users to configure their prompt, aliases, key bindings, and behavior through configuration files like .zshrc.
  3. Plugins and Extensions: Zsh supports plugins and extensions through frameworks like Oh My Zsh, which provide additional functionality such as syntax highlighting, auto-completion for various commands and programming languages, and integration with version control systems like Git.
  4. Powerful Scripting: Zsh offers advanced scripting features, including support for arrays, associative arrays, arithmetic expressions, and more, making it a powerful tool for writing shell scripts.
  5. Compatibility: Zsh is designed to be mostly compatible with Bourne Shell (sh) syntax, which means that many Bash scripts can run with Zsh without modification.

Overall, Zsh is a versatile and powerful shell that offers an improved command-line experience for both interactive use and scripting on Unix-based systems.

Recommended Training: Linux Command Line

4794154 0ec0 2show?id=oLRJ54lcVEg&offerid=1074652.4794154&bids=1074652

What is Oh My Zsh?

Oh My Zsh is a popular open-source framework for managing Zsh configurations. Zsh (Z Shell) is a powerful command-line interpreter for Unix-based systems, and Oh My Zsh enhances its capabilities by providing various plugins, themes, and helpers to customize and streamline the user’s command-line experience.

With this open-source framework, users can easily install and manage plugins for features such as syntax highlighting, auto-completion, and git integration, among others. It also offers a wide range of themes to customize the appearance of the terminal prompt.

Overall, Oh My Zsh is favored by many developers and power users for its flexibility and productivity-enhancing features in the command-line environment.

Oh My Zsh Installation:

Here, we are performing Oh My Zsh Installation on Rocky Linux 9, you can use the same steps for any other Red Hat based Linux distro.

You can install software prerequisites by executing dnf command.

dnf install -y zsh git

Now, you can invoke unattended installation of Oh My Zsh by using following command.

# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Cloning Oh My Zsh...
remote: Enumerating objects: 1386, done.
remote: Counting objects: 100% (1386/1386), done.
remote: Compressing objects: 100% (1332/1332), done.
remote: Total 1386 (delta 31), reused 1142 (delta 26), pack-reused 0
Receiving objects: 100% (1386/1386), 3.19 MiB | 723.00 KiB/s, done.
Resolving deltas: 100% (31/31), done.
From https://github.com/ohmyzsh/ohmyzsh
 * [new branch]      master     -> origin/master
branch 'master' set up to track 'origin/master'.
Already on 'master'
/root

Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to /root/.zshrc.

I can't change your shell automatically because this system does not have chsh.
Please manually change your default shell to zsh
         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....is now installed!


Before you scream Oh My Zsh! look over the `.zshrc` file to select plugins, themes, and options.

• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord community: https://discord.gg/ohmyzsh
• Get stickers, t-shirts, coffee mugs and more: https://shop.planetargon.com/collections/oh-my-zsh

➜  ~

Oh My Zsh has been installed on your Linux server.

Oh My Zsh Themes:

Oh My Zsh currently ships with 150 themes bundled.

Select a Theme:

Robby’s theme is the default one. which is a simple theme.

To use an alternate theme, you will need to edit the ~/.zshrc file.

# vi ~/.zshrc

Find following environment variable in this file.

ZSH_THEME="robbyrussell"

To use a different theme, simply change the value to match the name of your desired theme. For example:

ZSH_THEME="agnoster" 
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster

Note: Some themes require installing a Powerline Font or a Nerd Font in order to render properly. Without them, these themes will render weird prompt symbols.

You can access GitHub to find your favorite Oh My Zsh themes.

Open up a new terminal window and your prompt should look something like this:

oh my zsh screenshot

Set ZSH_THEME variable as follows to let the computer select a theme randomly for you, each time you open a new terminal window.

ZSH_THEME="random"

Set following variable, if you want to pick a random theme from a list of your favorite themes.

ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

If you only know which themes you don’t like, you can add them similarly to an ignored list.

ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)

Oh My Zsh Plugins:

Oh My Zsh comes bundled with plugins that’ll make your life as a software developer easier and leave you feeling like a superhero.

It includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.

Enable a Plugin:

Once you spot a plugin (or several) that you’d like to use with Zsh shell, you’ll need to enable them in the ~/.zshrc file. You’ll find the zshrc file in your $HOME directory. Open it with your favorite text editor and you’ll see a spot to list all the plugins you want to load.

vi ~/.zshrc

For example, this might begin to look like this:

plugins=(
  git
  bundler
  dotenv
  macos
  rake
  rbenv
  ruby
)

Note that the plugins are separated by whitespace (spaces, tabs, new lines…). Do not use commas between them or it will break.

Each built-in plugin includes a README, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.

Uninstall Oh My Zsh:

If you want to uninstall Oh My Zsh, just run uninstall_oh_my_zsh from the command-line. It will remove itself and revert your previous bash or zsh configuration.

Final Thoughts

As we wrap up our discussion on installing Oh My Zsh!, it’s clear that this tool offers developers a fantastic way to enhance their Linux shell experience. With its plethora of themes, plugins, and customization options, this fancy shell transforms the humble command line into a powerful and visually appealing environment.

By simplifying and streamlining common shell tasks, Oh My Zsh! not only boosts productivity but also adds a touch of flair to the developer workflow. Whether you’re a seasoned coder or just getting started, the convenience and flexibility provided by this fancy shell are undeniable.

Furthermore, the vibrant community surrounding Oh My Zsh! ensures that it remains constantly updated and supported, with new features and improvements regularly being introduced. This collaborative spirit fosters innovation and ensures that this fancy shell remains a cornerstone tool for developers worldwide.

In conclusion, if you haven’t already embraced Oh My Zsh!, now is the perfect time to do so. With its easy installation process and endless customization possibilities, it’s no wonder that this fancy shell has become the go-to choice for developers looking to elevate their Linux shell experience. So why wait? Install Oh My Zsh! today and unlock a world of possibilities right at your fingertips.