Install zsh - lightblueseas/linuxstuff GitHub Wiki
Install Zsh on Ubuntu or Manjaro
Installing Zsh
To install Zsh on your system, use the appropriate command for your distribution.
For Ubuntu/Debian-based systems:
sudo apt update -y
sudo apt install zsh -y
For Manjaro:
sudo pacman -Sy --noconfirm
sudo pacman -S zsh --noconfirm
Verify Installation
After installation, verify that Zsh is installed:
zsh --version
Set Zsh as Your Default Shell
To change your default shell to Zsh, run:
chsh -s $(which zsh)
Confirm the Default Shell
Check whether Zsh is set as your default shell:
echo $SHELL
If the output is /bin/bash
, you may need to log out and log back in or reboot your system for the changes to take effect.
You can automate all the above steps with the following script:
#!/bin/bash
# Detect OS
if [ -f /etc/os-release ](/lightblueseas/linuxstuff/wiki/--f-/etc/os-release-); then
source /etc/os-release
else
echo "Could not determine OS. Exiting."
exit 1
fi
if [ "$ID" == "manjaro" ](/lightblueseas/linuxstuff/wiki/-"$ID"-==-"manjaro"-); then
echo "Installing Zsh on Manjaro..."
# Update package database
sudo pacman -Sy --noconfirm
# Install Zsh
sudo pacman -S zsh --noconfirm
elif [ "$ID" == "ubuntu" ](/lightblueseas/linuxstuff/wiki/|-"$ID_LIKE"-==-*"debian"*-); then
echo "Installing Zsh on Ubuntu..."
# Update package database
sudo apt update -y
# Install Zsh
sudo apt install zsh -y
else
echo "Unsupported OS. Exiting."
exit 1
fi
# Verify Zsh installation
zsh --version
# Set Zsh as the default shell
chsh -s $(which zsh)
# Verify the default shell change
echo "Your current shell is: $SHELL"
# Prompt user to log out or restart if needed
echo "If the output above is still /bin/bash, please log out or reboot."
echo "When you open Zsh for the first time, you may see a configuration menu."
echo "Follow the prompts to configure your shell."
echo "To verify again, run: echo \$SHELL"
First-time Zsh Setup
When you start Zsh for the first time, you may see the following prompt:
This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no Zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory ~).
This function can help you with a few settings that should make your use of the shell easier.
You can:
(q) Quit and do nothing. The function will be run again next time.
(0) Exit, creating the file ~/.zshrc containing just a comment.
That will prevent this function from running again.
(1) Continue to the main menu.
(2) Populate your ~/.zshrc with the configuration recommended
by the system administrator and exit (you will need to edit
the file by hand, if so desired).
Choose your preferred option, and Zsh will start.
Final Verification
Run the following command to ensure Zsh is set as your default shell:
echo $SHELL
The expected output should be:
/usr/bin/zsh
For a detailed guide on installing and configuring Zsh with Oh-My-Zsh, visit Installing-Oh-My-Zsh.