#!/bin/bash

# This a the setup script for my config. The idea is to be able to run this after cloning my dotfiles repo on a Mac or Linux system
# and be up and running very quickly
#
# This script should be ran as sudo

export XDG_CONFIG_HOME="$HOME"/.config
mkdir -p "$XDG_CONFIG_HOME"/bash
mkdir -p "$XDG_CONFIG_HOME"/alacritty
mkdir -p "$XDG_CONFIG_HOME"/alacritty/themes
mkdir -p "$XDG_CONFIG_HOME"/karabiner

mkdir -p tmp

# Curl alacritty cappuccin-macchiato theme
curl -LO --output-dir ~/.config/alacritty https://github.com/catppuccin/alacritty/raw/main/catppuccin-macchiato.toml

# Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install alacritty
brew install --cask alacritty

# Install nerd font jetbrains
brew tap homebrew/cask-fonts
brew install --cask jetbrains-mono-nerd-font 

# Install nvim and AstroNvim
curl -L https://github.com/neovim/neovim/releases/download/stable/nvim-macos.tar.gz -o tmp/nvim-macos.tar.gz
tar xzvf tmp/nvim-macos.tar.gz
/bin/bash tmp/nvim-macos/bin/nvim
git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim
mkdir -p "$XDG_CONFIG_HOME"/nvim/lua/user
cp init.lua "$XDG_CONFIG_HOME"/nvim/lua/user/init.lua

# Install other Mac Packages
brew install --cask obsidian vlc firefox amethyst hiddenbar karabiner-elements bitwarden signal
brew install tmux starship ripgrep lazygit bottom wireguard-go ffmpeg gh

# Change default shell to bash
chsh -s /bin/bash

# Import config files
ln -sf "$PWD/alacritty.toml" "$HOME"/.alacritty.toml
ln -sf "$PWD/bash_profile" "$HOME"/.bash_profile
ln -sf "$PWD/bashrc" "$HOME"/.bashrc
ln -sf "$PWD/tmux.conf" "$HOME"/.tmux.conf
ln -sf "$PWD/karabiner.json" "$XDG_CONFIG_HOME"/karabiner/karabiner.json

# Install firefox addons (bitwarden, ublock, vimium, pocket)

# Clean installation packages
#rm -rf tmp
