#!/bin/sh

echo Installing Dependencies
if [ -f /etc/rocky-release ]; then
    sudo dnf install -y zsh git curl
elif [ -f /etc/arch-release ]; then
    sudo pacman -S zsh git curl
elif [ "$(uname)" = "FreeBSD" ]; then
    sudo pkg install -y zsh curl git
fi

echo Installing Oh My ZSH
export RUNZSH=no; sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

echo Switching Theme
sed -i 's/ZSH_THEME=.*/ZSH_THEME="bureau"/' ~/.zshrc

echo Enabling Plugins
sed -i 's/plugins=(git+*/plugins=(git zsh-autosuggestions zsh-syntax-highlighting/' ~/.zshrc

echo Installing AutoSuggestions
zsh -c "git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions"
echo Installing Syntax Highlighting
zsh -c "git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting"

echo Running Zsh

if [ "$(uname)" = "FreeBSD" ]; then
    sudo chsh -s "/usr/local/bin/zsh" "$(whoami)"
else
    sudo usermod -s /usr/bin/zsh "$(whoami)"
fi

zsh
