Complete guide for setting up ZSH with oh-my-zsh, autosuggestions, and importing your bash history.
Rocky Linux / RHEL / CentOS (adjust package manager for other distros)
# Install zsh
sudo dnf install zsh -y
# Verify installation
zsh --version
# Change default shell to zsh
chsh -s $(which zsh)
Note: You'll need to log out and back in for the shell change to take effect.
# Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
This will create a ~/.zshrc configuration file with sensible defaults.
# Clone to oh-my-zsh custom plugins directory
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# Add to plugins in ~/.zshrc
sed -i 's/^plugins=(git)$/plugins=(git zsh-autosuggestions)/' ~/.zshrc
# Reload configuration
source ~/.zshrc
Usage: Start typing a command you've used before. Gray text will appear suggesting the completion. Press → (right arrow) or End to accept.
# One-time import of bash history
if [ -f ~/.bash_history ]; then
cat ~/.bash_history >> ~/.zsh_history
fc -R
fi
Apply changes:
```bash
source ~/.zshrc
Makes valid commands green, invalid commands red:
# Install to custom plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# Add to plugins
sed -i 's/^plugins=(git zsh-autosuggestions)$/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/' ~/.zshrc
# Reload
source ~/.zshrc
Better Ctrl+R search through history:
# This one comes with oh-my-zsh, just add to plugins
sed -i 's/^plugins=(\(.*\))$/plugins=(\1 history-substring-search)/' ~/.zshrc
# Reload
source ~/.zshrc
ls ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
~/.zshrc: grep "plugins=" ~/.zshrc
Suggestions appear in gray. If your terminal theme makes this hard to see, change the color:
echo 'ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=240"' >> ~/.zshrc
source ~/.zshrc
source ~/.zshrc# Switch back to bash
chsh -s /bin/bash
# Remove oh-my-zsh
rm -rf ~/.oh-my-zsh ~/.zshrc
# Remove custom plugins
rm -rf ~/.zsh