#!/bin/bash
# Bacause of: https://www.reddit.com/r/archlinux/s/KTx9AbsFfT
pushd "${BASH_SOURCE%/*}" > /dev/null;

configFile="/etc/makepkg.conf";
customFile="$configFile.d/makepkg.conf";
pattern="^\\(OPTIONS=(.*[( ]\\)\\(debug[ )].*)\\)$";

if [ ! -f "$customFile" ];
then
    sed "/$pattern/{ s/$pattern/\\1!\\2/; p; }; d" "$configFile" | sudo tee "$customFile" > /dev/null;
    echo "MAKEFLAGS=\"-j\$(nproc)\"" | sudo tee --append "$customFile" > /dev/null;
fi;

popd > /dev/null;