Zsh (Z Shell) is an extended Bourne shell with many improvements, including powerful autocompletion and theming capabilities (via frameworks like Oh My Zsh). It is the default shell on macOS.
Installation
# Debian / Ubuntu
sudo apt install zsh
# Arch Linux
sudo pacman -S zsh
# macOS
brew install zshBasic Configuration
zsh --version # Check version
cat /etc/shells # List available shells
chsh -s $(which zsh) # Change default shell to Zsh (requires logout)
source ~/.zshrc # Reload configurationOh My Zsh (Popular Framework)
Oh My Zsh makes managing Zsh configuration, themes, and plugins much easier.
Installation
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"Configuration (~/.zshrc)
# Change theme
ZSH_THEME="robbyrussell" # e.g., "agnoster", "powerlevel10k/powerlevel10k"
# Enable plugins
plugins=(
git
docker
zsh-autosuggestions
zsh-syntax-highlighting
)Zsh Specific Features
Advanced Globbing
ls **/*.txt # Recursive search for .txt files
ls *(.) # Match only regular files
ls *(/) # Match only directories
ls *(@) # Match only symlinks
ls *(m-1) # Match files modified in the last 1 day
ls *(L+10M) # Match files larger than 10MBPath Replacement (Quick cd)
cd /var/log/apache2
cd apache2 nginx # Replaces 'apache2' with 'nginx' in the path, moving to /var/log/nginxHistory Expansion
!! # Run the last command
sudo !! # Run the last command with sudo
!$ # The last argument of the previous command
!* # All arguments of the previous command