updated zsh install script

This commit is contained in:
JaKooLit 2023-12-12 13:49:28 +09:00
parent d6c9ab0d74
commit 08aafc2135

View File

@ -48,8 +48,8 @@ install_package() {
if [ -d "$HOME/.oh-my-zsh" ]; then if [ -d "$HOME/.oh-my-zsh" ]; then
printf "${NOTE} Oh My Zsh found. Creating a backup before uninstalling...${RESET}\n" printf "${NOTE} Oh My Zsh found. Creating a backup before uninstalling...${RESET}\n"
# Perform backup using cp -r and create a backup directory with -backup suffix # Perform backup using cp -r and create a backup directory with -backup suffix
mv "$HOME/.oh-my-zsh" "$HOME/.oh-my-zsh-backup" cp -r "$HOME/.oh-my-zsh" "$HOME/.oh-my-zsh-backup" || true
mv "$HOME/.zshrc" "$HOME/.zshrc-backup" mv "$HOME/.zshrc" "$HOME/.zshrc-backup" || true
printf "${NOTE} Backup created....${RESET}\n" printf "${NOTE} Backup created....${RESET}\n"
fi fi
@ -67,7 +67,11 @@ done
# Install Oh My Zsh, plugins, and set zsh as default shell # Install Oh My Zsh, plugins, and set zsh as default shell
if command -v zsh >/dev/null; then if command -v zsh >/dev/null; then
printf "${NOTE} Installing Oh My Zsh and plugins...\n" printf "${NOTE} Installing Oh My Zsh and plugins...\n"
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended || true if [ ! -d "$HOME/.oh-my-zsh" ]; then
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended || true
else
echo "Directory .oh-my-zsh already exists. Skipping re-installation."
fi
# Check if the directories exist before cloning the repositories # Check if the directories exist before cloning the repositories
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]; then if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions || true git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions || true