DEV Community

Pepe
Pepe

Posted on

Zshell [My Dev Environment]

If you spend a good chunk of your day in the terminal, you know how much difference a well-tuned shell can make. For years, I worked with the default Bash setup. Yeah, it got the job done, but it always felt a bit… dull. Then I discovered Zsh, a powerful, extensible shell that turns the command line into a fast, elegant, and personalized workspace.

This blog post is my personal guide to configuring the command line with all the tools I use most often. So, let's start.

My preferred distro for development is Ubuntu (either as WSL or a standalone version)

First things first - update:

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

Then we can download the latest zshell from the repository:

sudo apt install zsh
Enter fullscreen mode Exit fullscreen mode

and make it your default shell

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

I’m using a combination of Oh My Zsh and Oh My Posh to take my Zsh setup to the next level. Oh My Zsh handles the core customization like managing plugins, aliases, and shell behavior, making the terminal faster and more capable. On top of that, Oh My Posh adds a beautiful, information-rich prompt with support for Git status, context awareness, and dynamic themes. Using both gives me the best of both worlds. However, in future I might end up with Oh My Posh only.

To display the icons correctly, we need to install Nerd Fonts. I am using MesloLG Nerd Font.

In WSL Terminal Settings, you have to configure it in your Ubuntu profile > Appearance > Font Face [MesloLGM Nerd Font].

Oh My Zsh installation

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

in your ~/.zshrc file create ZSH_CUSTOM environment variable. It will be used as a path to custom plugins.

export ZSH_CUSTOM="$HOME/.zsh_custom"
Enter fullscreen mode Exit fullscreen mode

Installation of plugins for autosuggestion and syntax highlighting:

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
Enter fullscreen mode Exit fullscreen mode

Again, let's update our ~/.zshrc config file

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
Enter fullscreen mode Exit fullscreen mode

Now we can install Oh My Posh:

curl -s https://ohmyposh.dev/install.sh | bash -s
Enter fullscreen mode Exit fullscreen mode

Changing our ~/.zshrc for the last time

export PATH=$HOME/.local/bin:$PATH
eval "$(oh-my-posh init zsh)"
Enter fullscreen mode Exit fullscreen mode
exec zsh
Enter fullscreen mode Exit fullscreen mode

Now we should have a prompt which looks like this:

I really love the default theme because it has everything I need for my job, including username, current folder, branch name, and current Git status, as well as providing visual information about the last successful/failed command. But you can choose from these themes here and you can even customize them.

Thanks for reading, and see you in my next blog post.
Happy coding!

Top comments (0)