dotfiles/scripts/linux-setup_zsh.sh
2025-02-24 09:51:41 +00:00

31 lines
726 B
Bash
Executable File

#!/bin/bash
set -e
if [ "$(id -u)" -ne 0 ]; then
echo "Please run this script as root: sudo $0"
exit 1
fi
# Check if Zsh is already installed
if command -v zsh &> /dev/null; then
echo "Zsh is already installed. Skipping installation."
else
echo "Updating package list..."
apt-get update
echo "Installing Zsh..."
apt-get install -y zsh
if ! command -v zsh &> /dev/null; then
echo "Error: Zsh installation failed."
exit 1
fi
fi
echo "Changing default shell to Zsh for user ${SUDO_USER:-$USER}..."
zsh_path=$(command -v zsh)
chsh -s "$zsh_path" "${SUDO_USER:-$USER}"
echo "Zsh installation and setup complete. Please log out and log back in for changes to take effect."