Wednesday, 19 February 2025

How to set up My Zsh and Oh My Zsh on Ubuntu, start by installing Zsh and some useful tools

Tools

  • Zsh: A powerful shell that operates as both an interactive shell and a scripting language interpreter.
  • curl: A command-line tool for transferring data with URLs, supporting various protocols.
  • autojump: A faster way to navigate your filesystem, learning your most frequently used directories.
  • fzf: A general-purpose command-line fuzzy finder, useful for searching files, command history, and more.
  • git: A distributed version control system for tracking changes in source code during software development.
  • bat: A `cat` clone with syntax highlighting and Git integration, enhancing the readability of code and text files.
sudo apt-get install zsh curl autojump fzf git bat -y

Then, install Oh My Zsh using the command:

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

Next, add some helpful plugins to enhance your Zsh experience. Clone the following repositories into your Oh My Zsh custom plugins directory:

Plugins

  • zsh-syntax-highlighting: This plugin provides syntax highlighting for commands typed in the Zsh prompt, making it easier to read and spot errors.
  • zsh-autosuggestions: This plugin suggests commands as you type based on your command history and completions, speeding up your workflow.
  • you-should-use: This plugin reminds you to use existing aliases and functions, helping you to optimize your command usage.
  • zsh-bat: This plugin integrates the `bat` command, a `cat` clone with syntax highlighting and Git integration, into your Zsh environment.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/MichaelAquilina/zsh-you-should-use.git $ZSH_CUSTOM/plugins/you-should-use
git clone https://github.com/fdellwing/zsh-bat.git $ZSH_CUSTOM/plugins/zsh-bat

Open your .zshrc file with:

nano ~/.zshrc

Add the plugins to the plugins list:

plugins=(git zsh-syntax-highlighting zsh-autosuggestions you-should-use zsh-bat)

Finally, apply the changes by running:

source ~/.zshrc

Best Zsh Tools and Plugins

  • Zsh: A powerful and flexible shell.
  • Oh My Zsh: A framework for managing your Zsh configuration.
  • zsh-syntax-highlighting: Enhances readability with syntax highlighting.
  • zsh-autosuggestions: Boosts productivity with command suggestions.
  • you-should-use: Optimizes command usage by suggesting aliases.
  • zsh-bat: Integrates the `bat` command for better file viewing.

These tools and plugins are some of the best for enhancing your Zsh experience, making your terminal more powerful and efficient.