MIAOU-BASH is a collection of scripts and configurations designed to enhance your terminal experience. As the name suggests, it is built on Bash and is designed to work on most modern GNU/Linux systems.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

#!/usr/bin/env bash
## CONSTANTS
MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
## FUNCTIONS
function upgrade {
echo UPGRADE
execute_miaou_lib self-upgrade
}
function install {
echo INSTALL
MIAOU_BASH_DIR=/opt/miaou-bash
export MIAOU_BASH_DIR
local tempfile
tempfile="/tmp/$(basename "$MAIN_TAR_GZ_URL")"
curl -sO $MAIN_TAR_GZ_URL >"$tempfile"
sudo tar -xzf "$tempfile" --directory "$(dirname "$MIAOU_BASH_DIR")"
rm "$tempfile"
execute_miaou_lib initiate
source /etc/profile
echo "miaou-bash successfully installed"
}
function assert_supported_distro {
if ! grep -E '^ID=debian|^ID_LIKE=debian' /etc/os-release &&
! grep -E '^ID=arch|^ID_LIKE=arch' /etc/os-release; then
local distro
distro=$(grep -oP '^ID=\K(.*)' /etc/os-release)
>&2 echo "unsupported GNU/Linux distribution: $distro"
>&2 echo 'only debian-like OR arch-like currently supported'
exit 2
fi
}
function once_installed {
[[ -v MIAOU_BASH_DIR && -d "$MIAOU_BASH_DIR" &&
-L /etc/inputrc &&
"$(readlink /etc/inputrc)" == "$MIAOU_BASH_DIR"/etc/inputrc ]]
}
function execute_miaou_lib {
sudo -E "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR"/lib/"$1".bash
}
function sudo_root {
[[ "$UID" -ne 0 ]] && sudo -vp 'SUDO privilege required: '
}
## MAIN
# source <(curl -s https://git.artcode.re/miaou/miaou-bash/raw/branch/main/install2.sh)
set -Eeuo pipefail
assert_supported_distro
sudo_root
if once_installed; then upgrade; else install; fi