#!/bin/bash

# Define color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color

# Packages list
packages=(
    "zsh"         # Better than bash
    "micro"       # Better than nano
    "exa"         # Better than ls
    "bat"         # Better than cat
    "btop"        # Betther than top
    "ncdu"        # Better than du -h
    "duf"         # Better than df -h
    "neofetch"    # Because it's cool
    "git"         # Because git
    "fuck"        # Fuck error
    "python3-pip" # PIP
)

# Scipts list
scripts=(
    "./DockerStatus.py"
)

# Packages installation
clear
echo "Mise à jour de la liste des paquets..."
echo " "
sudo apt update >/dev/null 2>&1
echo "Installation des paquets :"
for package in "${packages[@]}"; do
    if sudo apt install "$package" -y >/dev/null 2>&1; then
        echo -e "  - Installation de $package : ${GREEN}ok${NC}"
    else
        echo -e "  - Installation de $package : ${RED}échoué${NC}"
    fi
done

# Installation module tabulate
echo "Installation module tabulate via pip"
pip install tabulate

# Copie des Scripts dans ~/.scripts
echo ""
if [ ! -d ~/.scripts ]; then
  mkdir -p ~/.scripts
fi
echo "Copie des Scripts dans ~/.scripts :"
for script in "${scripts[@]}"; do
    cp "$script" ~/.scripts >/dev/null 2>&1
    echo -e "  - Copie de $script : ${GREEN}ok${NC}"
done

# Git Installation
mkdir ~/.zsh
if [ ! -d ~/.zsh ]; then
  mkdir -p ~/.zsh
fi
if git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions >/dev/null 2>&1 ; then
        echo -e "  - Installation de zsh-autosuggestions : ${GREEN}ok${NC}"
    else
        echo -e "  - Installation de zsh-autosuggestions : ${RED}échoué${NC}"
    fi
if git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting >/dev/null 2>&1 ; then
        echo -e "  - Installation de zsh-syntax-highlighting : ${GREEN}ok${NC}"
    else
        echo -e "  - Installation de zsh-syntax-highlighting : ${RED}échoué${NC}"
    fi
if git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.zsh/powerlevel10k >/dev/null 2>&1 ; then
        echo -e "  - Installation de powerlevel10k : ${GREEN}ok${NC}"
    else
        echo -e "  - Installation de powerlevel10k : ${RED}échoué${NC}"
    fi

echo "  - Copie des fichiers nécessaires à powerlevel10k"
cp ./p10k.zsh ~/.p10k.zsh
cp ./zshrc ~/.zshrc
echo "  - Copie des fichiers nécessaires à Neofetch"
if [ ! -d ~/.config/neofetch ]; then
  mkdir -p ~/.config/neofetch
fi
cp -r ./neofetch/* ~/.config/neofetch
echo "  - Mise en place de zsh par défaut (mot de passe nécessaire)"
chsh -s $(which zsh)