#!/usr/bin/zsh


echo -n "[*] Do you want to install all packages via pacman? [y/n] "
read yesno

if [[ "$yesno" == "y" ]]; then
    echo "[*] Installing most popular tools"
    # most important tools that are _always_ needed
    sudo pacman -Sy fzf fd neovim ripgrep nmap hexyl ctags git podman ueberzug duf exa i3blocks udiskie
fi


# .zpretzo
echo -n "[*] Do you want to install zpretzo? [y/n] "
read yesno

if [[ "$yesno" == "y" ]]; then
    cd $HOME
    [ ! -d "$HOME/.zprezto" ] && git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"

    setopt EXTENDED_GLOB
    for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
      rm -rf "${ZDOTDIR:-$HOME}/.${rcfile:t}"
      echo "[*] Symlinking $rcfile -> ${ZDOTDIR:-$HOME}/.${rcfile:t}"
      ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
    done
fi


echo -n "[*] Copy (and overwrite) dotfiles? [y/n] "
read yesno

if [[ $yesno -eq "y" ]]; then
    backup_dir=/tmp/dotfiles-backup-$(date "+%H%M%S")
    rsync --backup --backup-dir $backup_dir --exclude .git/ --exclude install.sh -r . $HOME
    echo "[+] Dotfiles installed :) Backup available @ $backup_dir"
fi


