Setting Up Zsh on Your PC or VPS

June 25, 2023 (1y ago)

Setting Up Zsh on Your PC or VPS

Zsh (Z shell) is a powerful shell with improved features over bash, including better tab completion, spelling correction, and customizable prompts. Here's how to set it up:

Installation

Linux

# Ubuntu/Debian
sudo apt install zsh
 
# CentOS/RHEL
sudo yum install zsh
 
# Arch Linux
sudo pacman -S zsh

macOS

macOS ships with Zsh by default since Catalina. For older versions:

brew install zsh

Windows

Install Windows Subsystem for Linux (WSL) and then install Zsh in your Linux distribution.

Making Zsh Your Default Shell

chsh -s $(which zsh)

Installing Oh My Zsh

Oh My Zsh provides themes and plugins to enhance Zsh:

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

Configuration

Edit ~/.zshrc to customize your setup:

Must-Have Plugins

VPS-Specific Setup

Final Touch

Restart your terminal or run source ~/.zshrc to apply changes.

Example Configuration

Here's an example of a .zshrc configuration file with some useful settings:

# Path to your oh-my-zsh installation
export ZSH="$HOME/.oh-my-zsh"
 
# Set theme
ZSH_THEME="agnoster"
 
# Enable plugins
plugins=(
  git
  docker
  npm
  z
  zsh-syntax-highlighting
  zsh-autosuggestions
)
 
# Source oh-my-zsh
source $ZSH/oh-my-zsh.sh
 
# Custom aliases
alias zshconfig="nano ~/.zshrc"
alias gst="git status"
alias ll="ls -la"
alias ..="cd .."
alias ...="cd ../.."
 
# Configure history
HISTSIZE=10000
SAVEHIST=10000

With this setup, you'll have a powerful and customized terminal experience that will significantly improve your productivity when working on your PC or VPS.