How do I make zsh look good?

Zsh is a robust command-line shell that offers several benefits over other shells, such as Bash. One of its most significant advantages is its extensibility, which makes it a popular choice among developers, system administrators, and power users. However, while its functionality is impressive, the default configuration of zsh leaves a lot to be desired regarding aesthetics.

In this blog post, we'll explore ways you can make zsh look good by customizing its appearance to suit your personal preferences.

Install a Color Scheme

The first thing you can do to improve the look of zsh is to install a color scheme. The default color scheme with zsh is relatively bland and can make it difficult to read the text on the screen. By installing a color scheme, you can make the text easier to read and add visual interest to the terminal.

One popular color scheme for zsh is "agnoster".

This scheme uses bright colors and distinctive symbols to make it easy to identify different parts of the terminal. To install this color scheme, you can use a tool like Oh My Zsh, which makes it easy to manage your zsh configuration. To install Oh My Zsh, run the following command in your terminal:

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

Once you have installed Oh My Zsh, you can change the color scheme by editing your .zshrc file. Open the file in your favorite text editor and find the line that sets the ZSH_THEME variable. Change the value to "agnoster" and save the file. Next time you open a terminal, you should see the new color scheme.

Customize the Prompt

Another way to make zsh look good is to customize the prompt. The prompt is the text that appears at the beginning of each line in the terminal. It can be customized to display different information, such as the current directory or the username. By customizing the prompt, you can make it easier to navigate the terminal and add some visual interest.

To customize the prompt, you can use the PROMPT variable in your .zshrc file. You can use several variables to display different information in the prompt. For example, you can use the variable to display the current directory in the prompt. To display the time, you can use the %T variable. You can also add color to the prompt using the %F %K variables.

Here's an example of a custom prompt that displays the current directory, the time, and the username:

PROMPT='%F{green}%n%f at %F{blue}%D{%I:%M:%S}%f in %F{magenta}%d%f $ '

This prompt sets the text color to green for the username, blue for the time, and magenta for the current directory. It also uses the %D variable to format the time in hours, minutes, and seconds.

Use Powerline Fonts

If you want to take the customization of zsh to the next level, you can use Powerline fonts. Powerline is a set of fonts that includes several special characters that can be used to create more complex and visually appealing prompts.

To use Powerline fonts, you first need to install them on your system. You can download the fonts from the Powerline Github repository and install them manually, or you can use a tool like Homebrew to install them automatically:

brew tap homebrew/cask-fonts
brew install --cask font-powerline-symbols

Once you have installed the fonts, you can configure zsh to use them by setting the POWERLEVEL9K_MODE variable in your .zshrc file. Here's an example of how to use the Powerline fonts with the "agnoster" color scheme:

POWERLEVEL9K_MODE='nerdfont-complete'
ZSH_THEME="agnoster"

This configuration sets the POWERLEVEL9K_MODE variable to use the complete Nerd Fonts, including the Powerline symbols. It also sets the ZSH_THEME variable to use the agnoster color scheme.

Install Plugins

Zsh has several plugins that can be used to extend its functionality and improve its appearance. These plugins are easy to install and can be managed using Oh My Zsh.

One popular plugin for zsh is the syntax highlighting plugin, which highlights commands and their arguments with different colors based on their syntax. This makes it easier to read and understand complex commands. To install the syntax highlighting plugin, run the following command in your terminal:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

Once you have installed the plugin, you can enable it by adding the next line to your .zshrc file:

plugins=(zsh-syntax-highlighting)

Another useful plugin is the autosuggestions plugin, which suggests commands as you type based on your command history. This can save you time and improve your productivity by reducing the amount of typing you need to do. To install the autosuggestions plugin, run the following command:

git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

To enable the plugin, add the next line to your .zshrc file:

plugins=(zsh-autosuggestions)

Customize the Terminal Background

Finally, you can improve the appearance of zsh by customizing the terminal background. Most terminal emulators allow you to set a custom background image or color, which can help to personalize your terminal and make it more visually appealing.

To set a custom background image, you can use a tool like iTerm2, a popular terminal emulator for macOS. iTerm2 allows you to set a custom background image by going to the Preferences menu and selecting the "Profiles" tab. You can choose the "Background" option and select an image file for your background.

If you prefer a solid background, you can set the background color using the terminal emulator's settings. For example, in iTerm2, you can set the background color by going to the "Colors" tab in the preferences menu and selecting the "Background" color option.

Conclusion

Customizing the appearance of zsh can help to improve your productivity and make your terminal experience more enjoyable. By installing a color scheme, customizing the prompt, using Powerline fonts, installing plugins, and customizing the terminal background, you can create a personalized and visually appealing terminal environment that suits your needs and preferences.

While there are many different ways to customize zsh, the methods described in this blog post should provide a good starting point for anyone looking to improve the appearance of their terminal. Whether you are a developer, system administrator, or power user, zsh is a powerful and flexible tool that can be customized to suit your workflow and aesthetic preferences.

Did you find this article valuable?

Support Mrugesh Mohapatra by becoming a sponsor. Any amount is appreciated!